When to use each Java Collections data structure
This question already has an answer here:
It depends on the performance characteristics and behavior you are looking for.
For example in a LinkedList add, delete, and retrieve are O(1) , O(1) , and O(n) , whereas for an ArrayList , the same operations are O(n) , O(n) , and O(1) if using get(int) and O(n) if using get(Object) . However ArrayList uses less memory than LinkedList per entry.
One often uses Vector<type> to add elements to the structure that are part of the same collection, but do not have any relationship to other members (other than being part of the same collection). A LinkedList indicates that there is some sort of ordering that is important among the members of the collection.
