1、Map
It is also a container interface, which stores paired data in the form of key and value pairs.
Map and Collection are two systems that have nothing to do with each other
1、HashMap
It is the implementation class of Map. The thread is not safe. You can use null as the key value, which is the most efficient.
2、Hashtable
It is the implementation class of Map, which guarantees thread safety through the synchronization method. You cannot use null as the key value, which is the least efficient
①、 Properties
It is a subclass of Hashtable, the persistent attribute set, and the stored key-value pairs are all String types, and null can not be used as the key value. It is thread-safe
3、ConcurrentHashMap
It is the implementation class of the Map inheritance class. It ensures thread safety by synchronizing code blocks. It is not possible to use null as the key value, which is more efficient.
Types 1, 2, and 3 are all implementation classes of the Map interface, which store data in the form of key-value pairs. There are also two traversal methods, one is entryset and the other is keyset.
2. Collection tools
Similar to Arrays, the collections tool class here operates on collections. They are all static methods and can be called directly (class name. method name).
Common methods:
1、static <T> boolean
addAll(Collection<? super T> c, T... elements)
将所有指定元素添加到指定 collection 中。
2、static <T> void
fill(List<? super T> list, T obj)
使用指定元素替换指定列表中的所有元素。
3、static <T extends Object & Comparable<? super T>>
T
max(Collection<? extends T> coll)
根据元素的自然顺序,返回给定 collection 的最大元素。
4、static <T extends Object & Comparable<? super T>>
T
min(Collection<? extends T> coll)
根据元素的自然顺序 返回给定 collection 的最小元素。
5、static void reverse(List<?> list)
反转指定列表中元素的顺序。
6、static <T> void
copy(List<? super T> dest, List<? extends T> src)
将所有元素从一个列表复制到另一个列表。
3. Generic
Used to constrain the type, only for the reference data type, when there is no agreement, the default is Object
T type
K key
V value value
E element
?Represents uncertain types are usually combined with the upper and lower limits of generics
? Super type: the lower limit at this time? The type represented by the subclass or the same type requires the minimum type to be the given type or its parent
? extends type: the upper limit at this time? represents the type of the parent type or the same type. The highest type is required to be the given type or its subclass