01/28

The Map interface specializes in the storage of key-value mapping data, and can operate on values ​​based on keys. The
most commonly used implementation class is HashMap

Common methods of Map interface

Insert picture description here

Traverse the Map collection

Method 1: Implement traversal through iterator Iterator
Method 2: Enhanced for loop
Method 3: Key-value pairs
Generic collections can constrain the types of elements in the collection.
Typical generic collections ArrayList, HashMap<K,V>
, <K,V> Indicates the element type in the
generic collection. The data in the generic collection is no longer converted to Object.
Except for specifying the element type in the collection, the usage of the generic collection is exactly the same as the collection learned before

Collections algorithm class

The Java collection framework saves the implementation of different data structure algorithms in the tool class. The
Collections class defines a series of static methods for manipulating collections.
Collections are different from Collections. The former is a collection operation class, and the latter is
provided by the collection interface Collections. Commonly used static method
sort(): sort
binarySearch(): find
max()\min(): find the maximum\minimum.
Collections class can sort collections, find and replace operations
to compare the size of objects of a class, this class To implement the Comparable interface,
rewrite the compareTo() method

Guess you like

Origin blog.csdn.net/jokertiger/article/details/113838843
28
01