This tutorial was created with Roy Nunez. To learn the basics of ArrayList check out their tutorial HERE.
As a refresher, an ArrayList is like an Array without a set size. Unlike Arrays however, ArrayLists can only consist of Objects and cannot hold primitive data types like ints and booleans. If you want to make an ArrayList that holds integers or booleans, you’ll have to use their corresponding Wrapper Classes such as Integer an Boolean.
ArrayList<Boolean> divisByThree = new ArrayList<Boolean>();
ArrayList<Integer> modThree = new ArrayList<Integer>();
Lets take our ArrayLists we defined above and initialize them with a loop like in the Array tutorial.
for (Integer i = 0; i <= 25; i++){
if ((i % 3) == 0){
divisByThree.add(true);
}else{
divisByThree.add(false);
}
modThree.add(i % 3);
}
ArrayLists also support a predefined sorting function.
import java.util.Collections;
Collections.sort(modThree);
// Sorts the values in modThree from lowest to highest
ArrayLists are slower to access than standard Arrays. This is because their undefined and variable size results in them not being store consecutively in memory. Rather an ArrayList stores each Object it contains at it’s own memory address and the ArrayList itself is stored as a consecutive series of references to those addresses.
I hope this more advanced dive on ArrayLists has been helpful to you in your programming endeavors. I can’t wait to see what you craft next!

Code Available at https://github.com/StrategicNPC/CollaberaJUMPProjects/tree/master/Code/ArrayListDemos

/cdn.vox-cdn.com/uploads/chorus_asset/file/10118545/Unsealed_Spellbook_rune.png)