When to use each Java Collections data structure

This question already has an answer here:

  • When to use LinkedList over ArrayList? 28 answers

  • 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.

    链接地址: http://www.djcxy.com/p/19982.html

    上一篇: 如何从List Set中决定应该使用哪个集合?

    下一篇: 何时使用每个Java Collections数据结构