Java collection classes are the most commonly used and frequently used classes in work. Compared with arrays (Array), collection classes have variable lengths and are more convenient for development.
Java collections are like containers that can store any type of data, and can also be combined with generics to store specific type objects. Java collections can be expanded dynamically while the program is running, growing as elements are added. In Java, collection classes usually exist in the java.util package.
Java collections are mainly composed of two major systems, namely Collection system and Map system. Collection and Map are the top-level interfaces in the two major systems respectively.
Collection mainly has three sub-interfaces, namely List , Set , and Queue . Among them, the elements in List and Queue are ordered and repeatable, while the elements in Set are unordered and cannot be repeated.
There are two main implementation classes in List: ArrayList and LinkedList; in Set, there is a HashSet implementation class; and Queue is a new collection that only appeared after JDK 1.5, and mainly exists in the form of arrays and linked lists.
Map belongs to the java.util package and is part of the collection, but it is independent of Collection and has no relationship. Map exists in the form of key-value, and the key must be unique. There are three main implementation classes: HashMap, HashTable, and treeMap.