Originally posted by Lawrence Chettiar:
Hence linkedlist is preferred where you wish to get the list of values in a sequential manner and Arraylist/vector is perferred where you need random lookup of values.
That is not really correct. Both, ArrayList and LinkedList are Lists and thus store the values in an ordered fashion. Search for a random element will require a serial lookup through the whole list.
Advantages and disadvantage of ArrayList and LinkedList arise from the fact that ArrayList is based on an array while LinkedList is beased on a linked list. Therefore, adding and removing elements from the middle of the list will be faster in a LinkedList than in an ArrayList (because of the shift of element positions). For this reason, stack style operation are faster in a LinkedList.
Memorywise, ArrayList should be more efficient than a LinkedList because LinkedList stores two references (front and back) per element. ArrayList will also be more efficient if you want to add tons on elements in one shot and then just reading the List (not adding/removing values).
HTH,
Paul.