Summary of Java collection classes

Source: Internet
Author: User

Now there are a lot of articles about the Java Collection class, but I recently saw a very interesting picture, basically to show the overall framework of the Java collection, very intuitive.


If you find the picture is not clear, click here to see a larger map


Here, the collection classes are divided into two large categories of map and collection.

The four classes (Dictionary, HashTable, vectors, stacks) that are in the upper-left corner of the picture are thread-safe, but they are all old legacy classes of the JDK and are now largely unused, with the corresponding substitution classes. Where map is used instead of the upper-left corner of the image, the Dictionary abstract class (the official map document contains instructions). The official recommendation is to replace it with the map interface. Also for Hashtable, the official recommended Concurrenthashmap to replace. Then the following vector is an implementation class below the list.


Then the top pink part is the collection class all interface diagrams. The structure of map is relatively simple, and the structure of collection is comparatively complex. Collection has three inherited interfaces: List, queue, and set.


The next green part is the main implementation class of the collection class. This is also the collection class that we use most often.


By implementing the interface classification:

Implementations of the map interface are: Enummap, Identityhashmap, HashMap, Linkedhashmap, Weakhashmap, TreeMap

The implementation of the list interface is: ArrayList, LinkedList

The implementation of the set interface is: HashSet, Linkedhashset, TreeSet

Implementations of the queue interface are: Priorityqueue, LinkedList, Arrayqueue


Classification of data structures based on the underlying implementation :

The bottom layer is implemented as an array: Enummap, ArrayList, Arrayqueue
The underlying is implemented as a linked list: Linkedhashset, LinkedList, Linkedhashmap
The bottom layer is implemented in the form of hash table: HashMap, HashSet, Linkedhashmap, Linkedhashset, Weakhashmap, Identityhashmap
The bottom layer is implemented in the form of red and black trees: TreeMap, TreeSet
The bottom layer is implemented in the form of a two-fork heap: priorityqueue


The bottom of the whole block is the class in the Java.util.concurrent package, according to the package name we can know that the class in the package is used to deal with various concurrency scenarios in Java programming.


Next trailer: A more detailed interpretation of the intermediate common collection classes (common implementations of the green section).

Tool Recommendation: http://grepcode.com/. Read the code artifact. This source reading site not only contains the vast majority of Java class Library source code, and the source code in the middle of the comments, jumps and so done a very good optimization, with it, to ensure that your source reading efficiency greatly improved.

Original source: http://pierrchen.blogspot.com/2014/03/java-collections-framework-cheat-sheet.html

Summary of Java collection classes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.