Collection class diagram in Java

Source: Internet
Author: User

Java Collection class relationship diagram:

List: Add/Remove/get/set.

1. arraylist: it is actually an array with a large capacity. Frequent addition or deletion is a nightmare and is suitable for random search;

2. pull list: added push/[Pop | remove | pull], which is actually removefirst;

3. Vector: A legacy product of history. The arraylist of the synchronous version is an odd and strange name,CodeIt is too similar to arraylist;

4. STACK: inherited from vector. Java does not actually have a pure stack. You can implement one by yourself. You can encapsulate the consumer list in a combination;

5. queue: Why is it here? It was originally a separate type. However, in Sun's JDK, the feature list is used to provide this function. The main method is offer/pull/PEEK.

 

Set: Add/Remove. What about get and set? Sorry, you can use the iterator or convert it to list.

1. hashset: It is easy to say that hashmap is used internally;

2. hashset: Same as above, implemented using linkedhashmap;

3. treeset: treemap.

 

Map: Put/get/remove.

1. hashmap/hashtable: the hash list. It is implemented using arrays like arraylist. exceeding the initial capacity will result in performance loss;

2. linkedhashmap: this class is somewhat interesting. It inherits from hashmap, but the chain table structure is implemented by rewriting the nested hashmap. Entry class, which also has the capacity problem;

3. properties: That's right. This is the inherited hashtable.

 

By the way, arrays. aslist, the implementation of this method depends on a nested class. This nested class is also called arraylist! It's too bad.

 

 

 

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.