vendredi 13 mars 2015

Java ArrayList storage



I know that ArrayLists references are stored contiguously in the heap. However, if I add in an element into the middle of an array list



ArrayList<Double> list = new ArrayList<Double>(Collections.nCopies(10, 6.5));

list.add(5, 20.0);


How does this change the way it is stored in the heap? Is the location of the first reference moved to a new memory cell or is everything just moved past the memory cell 5 moved down after 20.0 is inserted?




Aucun commentaire:

Enregistrer un commentaire