An object is only once in memory. Your first addition to list just adds the object references.

anotherList.addAll will also just add the references. So still only 100 objects in memory.

If you change list by adding/removing elements, anotherList won't be changed. But if you change any object in list, then it's content will be also changed, when accessing it from anotherList, because the same reference is being pointed to from both lists.

Answer from MicSim on Stack Overflow
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-list-add-addall-methods
How To Use add() and addAll() Methods for Java List | DigitalOcean
September 10, 2025 - ArrayList: O(1) amortized for add(E), O(n) for add(int, E) due to element shifting · LinkedList: O(1) for both variants, but with higher constant overhead due to node creation · Vector: Similar to ArrayList but with synchronization overhead ... package com.journaldev.examples; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class ListAddExamples { public static void main(String[] args) { // Example 1: Basic add() operations List<String> vowels = new ArrayList<>(); vowels.add("A"); // [A] vowels.add("E"); // [A, E] vowels.add("U"); // [A, E, U] System.ou
Discussions

What is the best way to add items to a list?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
20
12
April 22, 2022
Add elements of a list to the same list in java - Stack Overflow
But it is not guaranteed to. The Javadoc for addAll says: The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this list, and this list ... More on stackoverflow.com
🌐 stackoverflow.com
Is there a way to add elements to an Array List all at once?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
6
1
November 2, 2021
How to add gentoo-vm USE flag?
Normally I would add dev-java/openjdk gentoo-vm to /etc/portage/package.use/openjdk but emerging the package again shows me that the flag has not been set. Any difference I miss when using experimental USE flags? ... Thank you very much. That did the trick! ... How great it would have been if the answer was still here... :( ... jbootstrap is enabled. However eselect java-vm list ... More on reddit.com
🌐 r/Gentoo
3
1
April 30, 2020
People also ask

What is a linked list in Java?

A linked list in Java is a data structure that consists of a sequence of elements, each contained in a node. Nodes are chained together using pointers, with each node pointing to the next node in the sequence. The use of pointers allows for efficient insertion and deletion of elements as it does not require shifting elements, which is required when relying on simple arrays.

🌐
thospfuller.com
thospfuller.com › home › tutorials › java code examples › tutorial: quickly add elements to a list in java! 🚚
Tutorial: Learn how to add elements to a Java List now! 🚚
What is a linked list node in Java?
A linked list (java.util.LinkedList) node in Java is a basic element of a linked list data structure, consisting of two main components:
  1. The data part that stores the element's value, and
  2. a reference (or pointer) to the next node in the sequence, facilitating the link in the list.
🌐
thospfuller.com
thospfuller.com › home › tutorials › java code examples › tutorial: quickly add elements to a list in java! 🚚
Tutorial: Learn how to add elements to a Java List now! 🚚
What are linked lists good for in Java?

Linked lists in Java (java.util.LinkedList) are useful in scenarios where frequent insertion and deletion of elements is required, as these operations can be performed more efficiently than in arrays, because there's no need to shift elements. Linked lists (java.util.LinkedList) are also useful when the size of the data structure needs to be dynamically allocated.

🌐
thospfuller.com
thospfuller.com › home › tutorials › java code examples › tutorial: quickly add elements to a list in java! 🚚
Tutorial: Learn how to add elements to a Java List now! 🚚
🌐
iO Flood
ioflood.com › blog › java-list-add
Adding Elements to a List in Java: A How-To Guide
February 27, 2024 - In this example, we create a new ArrayList and use the add() method to insert the string ‘Hello’ into the list. The output shows that the list now contains one element: ‘Hello’. This is a basic way to use the add() method in Java, but ...
🌐
TutorialsPoint
tutorialspoint.com › article › how-do-i-insert-all-elements-from-one-list-into-another-in-java
How do I insert all elements from one list into another in Java?
June 13, 2025 - We can use a ListIterator to traverse the source list and add each element to the destination list. In the following example, we will create a source list and a destination list, and then use a ListIterator to insert all elements from the source list into the destination list. import java.util.ArrayList; import java.util.List; import java.util.ListIterator; public class InsertAllElements { public static void main(String[] args) { List<Integer> sourceList = new ArrayList<>(); sourceList.add(1); sourceList.add(2); sourceList.add(3); List<Integer> destinationList = new ArrayList<>(); destinationL
Find elsewhere
🌐
Thospfuller
thospfuller.com › home › tutorials › java code examples › tutorial: quickly add elements to a list in java! 🚚
Tutorial: Learn how to add elements to a Java List now! 🚚
May 27, 2025 - In this Java Code Example, we’ll learn how to add elements to a List in Java via the constructor, by invoking the add and addAll methods, by calling the addFirst and addLast methods, and finally by invoking the push method.
🌐
Python Examples
pythonexamples.org › java › how-to-append-a-list-to-another-list
How to Append a List to another List in Java
Finally, we print the updated list1 to standard output. import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { List<Integer> list1 = new ArrayList<>(); List<Integer> list2 = List.of(4, 5, 6); list1.addAll(list2.stream().collect(Collectors.toList())); System.out.println("Updated list: " + list1); } }
🌐
Jenkov
jenkov.com › tutorials › java-collections › list.html
Java List
By default you can put any Object into a List, but from Java 5, Java Generics makes it possible to limit the types of object you can insert into a List. Here is an example: ... This List can now only have MyObject instances inserted into it. You can then access and iterate its elements without casting them. Here is how it looks: List<MyObject> list = new ArrayList<MyObject>(); list.add(new MyObject("First MyObject")); MyObject myObject = list.get(0); for(MyObject anObject : list){ //do someting to anObject...
🌐
JavaBeat
javabeat.net › home › list of lists in java: how to create, iterate, and access it
List of Lists in Java: How to Create, Iterate, and Access it
March 20, 2024 - Since, each element of a list of lists is also a list, so we use the asList() method three times to add three lists as elements of the exampleLists. On successful execution, you will get the following output on the console: Alternatively, you ...
🌐
Coderanch
coderanch.com › t › 676345 › java › access-add-element-list-lists
How to access and add an element to a list of lists [Solved] (Beginning Java forum at Coderanch)
February 19, 2017 - I aim to print a list of lists containing entry and exit times in the 24 hour decimal format from the "AM"-"PM" String format input by the user as a String array like this: 6AM#8AM 11AM#1PM 7AM#8PM 7AM#8AM 10AM#12PM 12PM#4PM 1PM#4PM 8AM#9AM I declared the individual lists inside the for loop and assigned them values inside the loop but again got the following run time exception from my code: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
🌐
Runestone Academy
runestone.academy › runestone › static › JavaReview › ListBasics › listAdd.html
9.11. Adding Values to a List — AP CSA Java Review - Obsolete
This would be true if the add(2, new Integer(4)) replaced what was at index 2, but it actually moves the value currently at index 2 to index 3. You can step through the code above by clicking on the following Example-8-5-1. 8-5-5: What will print when the following code executes? List<String> list1 = new ArrayList<String>(); list1.add("Anaya"); list1.add("Layla"); list1.add("Sharrie"); list1.add(1, "Sarah"); System.out.println(list1);
🌐
Baeldung
baeldung.com › home › java › java list › working with a list of lists in java
Working With a List of Lists in Java | Baeldung
April 3, 2025 - Then, we add the new list to listOfLists in the position with index=2. Again, after the assertions, we print the content of listOfLists: List of Lists ------------------------------------- Linux, Microsoft Windows, Mac OS, Delete Me Kotlin, Delete Me, Java, Python Slack, Zoom, Microsoft Teams, Telegram Delete Me, Mercurial, Git, Subversion
🌐
W3Schools
w3schools.com › java › ref_arraylist_add.asp
Java ArrayList add() Method
Java Data Structures Java Collections ... Java List Sorting Java Set Java HashSet Java TreeSet Java LinkedHashSet Java Map Java HashMap Java TreeMap Java LinkedHashMap Java Iterator Java Algorithms · Java Wrapper Classes Java Generics Java Annotations Java RegEx Java Threads Java Lambda Java Advanced Sorting ... How Tos Add Two Numbers ...
🌐
Coderanch
coderanch.com › t › 682316 › java › adding-List
adding to a List (Beginning Java forum at Coderanch)
July 19, 2017 - Instead, it returns a special implementation of interface List that reflects what is in the array that you created the list from. This special implementation of List does not allow elements to be added to it - that's why you get an UnsupportedOperationException when you try to call the add(...) method on it.
🌐
Baeldung
baeldung.com › home › java › java collections › add multiple items to an java arraylist
Add Multiple Items to an Java ArrayList | Baeldung
January 8, 2024 - One of them is addAll, which needs a destination list and the items to be added may be specified individually or as an array.
🌐
How to do in Java
howtodoinjava.com › home › collections framework › java arraylist › java arraylist add() – add a single element to list
Java ArrayList add() - Add a Single Element to List
August 7, 2023 - The ArrayList.add() in Java adds a single element to the list, either at the end of the list or at the specified index position. Always use generics for compile-time type safety while adding the element to the arraylist.
🌐
How to do in Java
howtodoinjava.com › home › collections framework › java arraylist › java arraylist.addall() – add multiple items to a list
Java ArrayList.addAll() - Add Multiple Items to a List
August 7, 2023 - The addAll() is one such method to add multiple elements in a single statement. Although, if generics are not used, it is the programmer’s responsibility to ensure that the argument collection has the same type of elements as in the current arraylist. Happy Learning !! ... A fun-loving family man, passionate about computers and problem-solving, with over 15 years of experience in Java and related technologies.