JAVA simple container classification and JAVA simple container classification

Source: Internet
Author: User

JAVA simple container classification and JAVA simple container classification

Figure:Commonly used containers are displayed in a purple rough box;

The dotted box indicates the interface, and the solid box indicates normal (specific class );

A dot line with a hollow arrow indicates that a specific class implements an interface;

A solid arrow indicates that a class can generate the object pointed to by the arrow.

Container usage summary:

1. Collection stores a single element, while Map stores the associated key-value pairs.

2. Like an array, the List also establishes a digital index and object Association. Therefore, arrays and lists are sorted containers. List can be automatically resized.

3. If you want to perform a large number of random access, use ArrayList. If you want to insert or delete elements from the middle of the table frequently, use explain list.

4. Map is a design that associates objects (rather than numbers) with objects. HashMap is designed for fast access. TreeMap keeps the "key" in the sorting state, so there is no HashMap fast. LinkedHashMap maintains the order of element insertion, but it also provides fast access through hash.

5. Set does not accept repeated elements. HashSet provides the fastest query speed, while TreeSet keeps elements in order.

LinkedHashSet stores elements in the insert sequence.

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.