aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes When do we use ArrayList, Vector and LinkedList Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "When do we use ArrayList, Vector and LinkedList" Watch "When do we use ArrayList, Vector and LinkedList" New topic
Author

When do we use ArrayList, Vector and LinkedList

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
ArrayList : when we need fast iteration

Vector : when we need thread safety since Vector methods are synchronised by default.

LinkedList: when do we use linkedlist ??

Also any practical examples, where we could use each of the above ?
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

ArrayList is fast in random access. If I want to get the 8th element then the 3rd element then the 7th and then the 2nd element, ArrayList will provide the best performance. LinkedList is slow in random access

LinkedList is used when you modify the list a lot. If you'll add and remove elements to the List a lot of times, LinkedList should be used. ArrayList is slow in terms of additions and removal...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: When do we use ArrayList, Vector and LinkedList
 
Similar Threads
which container is best for sorting
asList
Collections - A question on iterator.
vectors-arrays
ArrayList vs LinkedList !!