aspose file tools*
The moose likes Beginning Java and the fly likes Difference between ArrayList, LinkedList and Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between ArrayList, LinkedList and Vector" Watch "Difference between ArrayList, LinkedList and Vector" New topic
Author

Difference between ArrayList, LinkedList and Vector

Santosh Nijalingappa
Greenhorn

Joined: Feb 03, 2008
Posts: 3
What is the difference between ArrayList, LinkedList and a Vector?. All that i know is that they implement the List Interface.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41874
    
  63
  • 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 ]

    Ping & DNS - my free Android networking tools app
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Difference between ArrayList, LinkedList and Vector