Mega Code Archive

 
Categories / Java Tutorial / Collections
 

ArrayList Class

The ArrayList class is the Collection Framework's replacement for the Vector class. The main difference is: ArrayList is not synchronized by default, whereas Vector is. Both maintain their data in an ordered fashion. Ordered means the elements are held according to the positional index inserted, sorted refers to the comparison of element values for ordering. The ArrayList and Vector provide quick, random access to elements at a cost of slower insertion and deletion of those elements not at the end of the list. If you need to frequently add and delete elements from the middle of the list, consider using a LinkedList.