First, interface map<k,v>
1.V put (K key, V value)
2.int size ()
3.public class Hashmap<k, v> implements Map<k, v>
The hash value of the key is stored, when put, the key will be replaced, a key value can only correspond to one value
Traversal of 4.Map
Map does not have iterators, traversing through keyset () and values ()
Set<k> KeySet ()
Collection<v> VALUES ()
5.set<map.entry<k,v>> EntrySet ()
public static Interface Map.entry<k,v>
6.V get (Object key)
7.LinkedHashMap
TreeMap
Second, generic type
1.instanceOf
o instanceof Student
Determine if object o belongs to the student class
2. Generics can only add class types and cannot add basic data types, but basic data types will automatically box-and-unboxing
3. A class can have more than one generic
Map<string, student>
List<list<student>>
Map<string,list<student>>
Third, sort
1.comparable<t> interface
A class can define a comparison method for the class by implements the interface and implementing its int compareTo (T o) method, returning an int value
PS: This sort of implementation of sorting method and class binding, rather than comparator flexible
2. Interface comparator<t>
int compare (t O1, T O2)
Define a class, implements the comparator interface, implement the Compare method, pass the object of this class to the sort method (such as Collections.sort or Arrays.sort), implement a custom collation, complete the sort of list, etc.
Iv. Collections
1. Java.util.Collections
The 2.Collections class contains a number of static methods that implement multiple operations on the collection
3.static <t extends Object & comparable<? Super t>> T Max (collection<? extends t> Coll)
Returns the maximum element of the given collection, according to the natural ordering of its elements.
V. Collection-related
1. Set-to-go array
ToArray method in Collection interface <T> t[] ToArray (t[] a)
The method is implemented in a specific collection, and the collection can be converted directly to an array
2. Array to set
There is no ready way to write yourself
3. Enhanced for Traversal collection
The collection can be traversed using the For-each loop
Java Learning Diary Collection