You are adding the same ArrayState object every time. You should create a new ArrayState object every time in the while loop to avoid it getting changed every time. This is because by default objects are always passed by reference in Java. Try doing this:

ArrayList arrayListIdle = new ArrayList();


while(rs.next){

    state = new State();
    List<State> arrayState = new ArrayList<State>();

    state.updateStateArray(arrayState);//This function mods the elements of (arrayState);//This 
    state.setArrayStates(arrayState);//add a list of arrayState to the object state
    arrayListIdle.addAll(state);

}
Answer from Sapan Diwakar on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › List.html
List (Java Platform SE 8 )
April 21, 2026 - The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.) Specified by: addAll in interface Collection<E> Parameters: c - collection containing elements to be added to this list ·
🌐
GeeksforGeeks
geeksforgeeks.org › java › list-addall-method-in-java-with-examples
List addAll() Method in Java with Examples - GeeksforGeeks
January 2, 2019 - boolean addAll(Collection c) Parameters: This function has a single parameter, i.e, Collection c, whose elements are to be appended to the list. Returns: It returns true if the elements of specified list is appended and list changes.
🌐
CodeGym
codegym.cc › java blog › java collections › java arraylist addall() method
Java ArrayList addAll() method
October 11, 2023 - Here they are. boolean ... importantly, it adds all elements of the specified collection into the end of this list, in the order that they are returned by the specified collection's Iterator....
🌐
W3Schools
w3schools.com › java › ref_arraylist_addall.asp
Java ArrayList add() Method
The addAll() method adds all of the items from a collection to the list. If an index is provided then the new items will be placed at the specified index, pushing all of the following elements in the list ahead.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-list-add-addall-methods
How To Use add() and addAll() Methods for Java List | DigitalOcean
September 10, 2025 - addAll(Collection<? extends E> c): Appends all elements from the specified collection to the end of the list.
🌐
Medium
medium.com › @AlexanderObregon › javas-collections-addall-explained-fbed9a316bb2
Java’s Collections.addAll() Explained | Medium
September 25, 2024 - You should use Collections.addAll() whenever you need to add multiple elements to a collection. This method is particularly useful in scenarios where you want to initialize a collection with several elements or bulk-load a collection from another ...
Find elsewhere
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › java-arraylist-addall-int-index-collection-c-method-example
Java ArrayList addAll(int index, Collection c) Method example
November 3, 2022 - In the last tutorial we have shared the example of addAll(Collection c) method which is used for adding all the elements of Collection c at the end of list. Here we will see another variant add(int index, Collection c) which adds all the elements of c at the specified index of a list. ... In this example we have two ArrayList of String type and we are adding the element of second arraylist at the 3rd position(index =2) of first arraylist. package beginnersbook.com; import java.util.ArrayList; public class ExampleOfaddAllMethod { public static void main(String[] args) { // ArrayList1 ArrayList<
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-util-arraylist-addall-method-java
Java ArrayList addall() Method with Example - GeeksforGeeks
December 10, 2024 - Now, there are two versions of the ArrayList addAll() method, i.e., one that appends elements at the end of the list and another that inserts elements at a specified position in the list. This version appends all elements of the specified collection to the end of the ArrayList. ... Parameters: c: The collection containing elements to be added to the ArrayList. Return Value: true: If the elements were successfully added. ... // Java program to demonstrate // adding all elements at the end of ArrayList import java.util.ArrayList; public class GFG { public static void main(String[] args) { ArrayList<Integer> l1 = new ArrayList<>(); l1.add(10); l1.add(20); ArrayList<Integer> l2 = new ArrayList<>(); l2.add(30); l2.add(40); // Adding all elements from // l2 to l1 l1.addAll(l2); System.out.println("Final ArrayList: " + l1); } }
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › ArrayList.html
ArrayList (Java Platform SE 8 )
April 21, 2026 - clear in interface List<E> Overrides: clear in class AbstractList<E> public boolean addAll(Collection<? extends E> c) Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator.
🌐
TutorialsPoint
tutorialspoint.com › java › util › arraylist_addall_index.htm
Java.util.ArrayList.addAll() Method
The java.util.ArrayList.addAll(int index, Collection<? extends E> c) method inserts all of the elements in the specified collection into this list, starting at the specified position.
🌐
Codekru
codekru.com › home › linked list – addall method in java
Linked List - addAll method in Java - Codekru
June 5, 2022 - import java.util.LinkedList; import java.util.Vector; public class Codekru { public static void main(String[] args) { LinkedList<String> linkedList = new LinkedList<String>(); // making a linkedList object // adding elements to linked list linkedList.add("Pre"); linkedList.add("Filled"); linkedList.add("Linked List"); Vector<String> vector = new Vector<String>(); // making a vector object // adding elements to vector vector.add("hello"); vector.add("codekru"); linkedList.addAll(vector); // using addAll method System.out.println(linkedList); } }
🌐
Modrinth
modrinth.com › datapack › allthemons
AllTheMons [Cobblemon] - Minecraft Data Pack
A combination of several datapacks, with permission from the creators. More info on the discord and in the description. - Download the Minecraft Data Pack AllTheMons [Cobblemon] by a creator on Modrinth
🌐
Coderanch
coderanch.com › t › 628721 › java › Implementation-addAll-ArrayList-LinkedList
Implementation of addAll in ArrayList and LinkedList. (Java in General forum at Coderanch)
February 13, 2014 - Avor Nadal wrote:Why don't these classes first check if the passed Collection is of the same class to try to take advantage of the equality of the internal structure? Because the argument to addAll is limited; it's addAll(Collection<? extends E> c), so unless you explicitly try to fool the compiler you can't even pass anything that isn't compatible.
🌐
Vultr
docs.vultr.com › java › standard-library › java › util › ArrayList › addAll
Java ArrayList addAll() - Add Collection Elements | Vultr Docs
September 27, 2024 - The addAll() method in Java's ArrayList class is a critical tool for developers, providing a way to add all elements of a collection to an ArrayList. This method is especially useful when you need to merge data from multiple collections without ...
🌐
TutorialKart
tutorialkart.com › java › java-arraylist-addall
Add All Elements of Collection to ArrayList
June 26, 2021 - To add all elements of a collection to an ArrayList in Java, we can use addAll() method of ArrayList class.
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-add-all-items-from-a-collection-to-an-arraylist-in-java
How to Add All Items From a Collection to an ArrayList in Java? - GeeksforGeeks
July 12, 2025 - In Java, to add all items from a collection to an ArrayList we use the addAll() method. This method appends all elements from a specified collection to the end of the list.