I\'m a little confused on what it means about ArrayLists holding references to objects. Can someone give me an example on how this is shown in code? Also, can arraylist have an
It means instead of copying the object byte-for-byte, a reference to the location of memory where the object is stored is put in the list.
List objects = new ArrayList(); Object myObject = new Object(); objects.add(myObject); // objects contains one reference to myObject objects.get(0).modify(); // myObject modified
Note that primitive values (int for example) will be copied.
int