在这个问题中 最简单的归因是链接到这个问题或这个答案.
其他资源
可能最有用的其他参考资料是 oracle 文档中的以下页面,它描述了每个 集合.
HashSet vs TreeSet
这里有关于何时使用 HashSet 或 TreeSet 的详细讨论:哈希集与树集
ArrayList 与 LinkedList
详细讨论:何时使用LinkedList over ArrayList?
In this question How can I efficiently select a Standard Library container in C++11? is a handy flow chart to use when choosing C++ collections.
I thought that this was a useful resource for people who are not sure which collection they should be using so I tried to find a similar flow chart for Java and was not able to do so.
What resources and "cheat sheets" are available to help people choose the right Collection to use when programming in Java? How do people know what List, Set and Map implementations they should use?
解决方案Since I couldn't find a similar flowchart I decided to make one myself.
This flow chart does not try and cover things like synchronized access, thread safety etc or the legacy collections, but it does cover the 3 standard Sets, 3 standard Maps and 2 standard Lists.
This image was created for this answer and is licensed under a Creative Commons Attribution 4.0 International License. The simplest attribution is by linking to either this question or this answer.
Other resources
Probably the most useful other reference is the following page from the oracle documentation which describes each Collection.
HashSet vs TreeSet
There is a detailed discussion of when to use HashSet or TreeSet here: Hashset vs Treeset
ArrayList vs LinkedList
Detailed discussion: When to use LinkedList over ArrayList?
更多推荐
我应该使用哪个 Java 集合?
发布评论