Java Collection framework knowledge Summary

Source: Internet
Author: User

1. Summary

All collection classes are located under the java. util package. Only objects can be saved in the collection (the object reference variable is saved ). (Arrays can save both basic data and objects ).

When we put an object into a collection, the system treats all the collection elements as instances of the object class. After jdk1.5, this state has been improved: You can use generics to restrict the types of elements in a set and let the set remember the types of all the set elements.

Java's collection classes are derived from two main interfaces: Collection and map. Collection and map are the root interfaces of the Java Collection framework. These two interfaces contain some interfaces or implementation classes.

The Set and list interfaces are two subinterfaces derived from the collection interface, and the queue is the queue implementation provided by Java, similar to the list.

Map implementation class is used to save key-value data with ing relationships ).

 

Set, list, and map can be viewed as three types of sets.

The list set is an ordered set. The elements in the set can be repeated. The elements in the access set can be accessed Based on the element index.

The Set set is an unordered set. Elements in the set cannot be duplicated. Elements in the set can only be accessed Based on the element itself (which is also the reason that the elements in the set cannot be duplicated ).

Elements in the form of key-value pairs stored in the map set can only be accessed based on the key of each element.

 

For set, list, and map sets, the most common implementation classes are hashset, arraylist, and hashmap.

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.