When to use ArrayList ,LinkedList,Vector?


Consider a list collection. Now lets consider some scenario:

1) the list needs to be modify such that the elements are added only at the end of list, and if required only the last element of the list to be deleted, use ArrayList

2) the list needs to be modify such that the elements can be added at any position of the list, and if required the element can be deleted from any position, use LinkedList

3) the list needs to be threadsafe, use Vector.

4) the list is read only and needs to be iterated frequently, use ArrayList

Leave a comment