Is the ArrayList order guaranteed

  • Thread starter Thread starter Jesper Denmark
  • Start date Start date
J

Jesper Denmark

Hi,

I use the ArrayList to store objects. Is the sequence of
the objects guaranteed or is it possible that the
framework reordes the object sequence in some memory
handling task? Know its maybe an odd question but I
remember from STL that some collections didn't guarantee
this.

Thanks.
Jesper.
 
Jesper,

For your purposes, you can assume that if you place an item at index
one, then it will stay at index one until it is changed by you or code you
call. The framework will not change the index. The memory where objects
are located might be rearranged, but it will not affect the index that is
stored at in the ArrayList.

Hope this helps.
 
Back
Top