Difference between ArrayList, LinkedList and Vector
Joined: Feb 03, 2008
What is the difference between ArrayList, LinkedList and a Vector?. All that i know is that they implement the List Interface.
Joined: Mar 22, 2005
ArrayList is in most cases what you want to use. It is a list backed by an array, which means it has fast access to each element via the get method.
Vector is a leftover from the early days of Java, retrofitted with the List interface. The chief difference from ArrayList is that its methods are synchronized (ArrayList's are not). That means it is easier to use in multi-threaded environments, but it does incur the synchronization overhead.
LinkedList is backed by a doubly-linked list, not an array. That means it's fast to access elements at the start and the end of the list, but less so in the middle. On the other hand, inserting and deleting elements is fast compared to ArrayList.
[ February 10, 2008: Message edited by: Ulf Dittmer ]