A picture that lets you see the Java Collection Class (Summary of Java collection classes)

Source: Internet
Author: User

There are so many articles about the Java Collection Class today, but I recently saw a very interesting picture that basically shows the overall framework of the Java collection. Very intuitive.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvawftenaymda4/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast "align=" Middle ">

Suppose that the picture is not clearly seen. Click here to see the big picture


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

The four classes (Dictionary, HashTable, vectors, stacks) in the upper-left corner of the picture are thread-safe, but they are all old legacy classes of the JDK. The basic is not how to use today, all have the corresponding substitution class. The map is used to replace the dictionary abstract class in the upper left corner of the image (as stated in the map's official document).

The official recommendation is to use the map interface to replace it. Same for Hashtable. Officially 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 diagram.

The structure of the map is simpler, and the structure of collection is relatively 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.


According to the implementation of 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 this package is used to deal with various concurrency scenarios in Java programming.


Next trailer: A more specific interpretation of the intermediate frequently used collection classes (the green part of the frequently used implementation class).

Tool Recommendation: http://grepcode.com/.

Read the code artifact. This source code reading site not only includes the vast majority of Java library Source code, and the source code in the middle of the gaze, jump and so do a very good optimization. With it, to ensure that your source code reading efficiency greatly improved.

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





A picture that lets you see the Java Collection Class (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.