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.