Collection:list list, set set
Map:hashtable,hashmap,treemap
Collection is a single-column collection
List elements are ordered, repeatable
Ordered collection, you can precisely control the insertion position of each element in the list.
You can access elements based on the integer index of an element (where it is located in the list) and search for the elements in the list.
Can hold duplicate elements, element access is ordered.
Common classes in the list interface
L Vector: Thread-safe, but slow, has been replaced by ArrayList.
The underlying data structure is the array structure
L ArrayList: Thread is unsafe and query speed is fast.
The underlying data structure is the array structure
L linkedlist: Thread is not secure. and delete the speed quickly.
The underlying data structure is the list structure
Set Set elements are unordered and non-repeatable.
The method of removing an element is only an iterator. Duplicate elements cannot be stored, and element access is unordered.
Common classes in the set interface
L HashSet: Thread is unsafe, access speed is fast.
How does it guarantee the uniqueness of the elements? Depends on the Hashcode method of the element and the Euqals method.
L TreeSet: Thread is unsafe, you can sort the elements in the set collection.
How is it sorted? The uniqueness of elements is ensured by CompareTo or compare methods. Elements are stored in the form of a two-fork tree.
Map is a two-column collection
|--Hashtable: Thread safe, fast. The bottom layer is the hash table data structure. is synchronous .
Null is not allowed as a key, and Null is used as a value.
|--Properties: Used for the definition and operation of configuration files, with very high frequency, and both keys and values are strings.
is an object in the collection that can be combined with IO technology. (To IO in learning its unique and IO-related features.) )
|--HashMap: Thread is unsafe and slow. The underlying is also a hash table data structure. is out of sync .
Null is allowed as the key, and null as the value. Replaced the Hashtable.
|--Linkedhashmap: Can guarantee the HashMap set in order. The order in which they are deposited is consistent with the order taken.
|--TreeMap: Can be used to sort the keys in the Map collection.
The difference between Collection and collections
Collection is the ancestor interface of the collection class, and the sub-interfaces are mainly set and list, Map.
Collections is a helper class for a collection class that provides a tool method for manipulating collections: A series of static methods for searching, sorting, threading, and so on for various collections.
"Java face question" 31 introduces the structure of the collection framework