December 17 Lessons Learned

Map interface to common methods
Void clear (); Removes all mappings
Boolean containsKey (object key) comprises a mapping relationship is determined whether the specified key, comprising a return to true
Boolean the contains the Value (Object Key) comprises determining whether the mapping for the specified value, returns true comprising
V get (object key) returns the specified key mapping, if there is no null is returned
Int hashCode () returns the hash code value mapping views
Boolean isEmpty ()

Map HashMap and treeMap are two common implementation class system, which is characterized as follows:
HashMap Map interface implementation class is based on the hash algorithm, the implementation class before doing all mappings, and allowing null null keys and values, but not order to ensure that the mapping, i.e. mapping a set of unordered;
the map interface is based on class TreeMap "tree" structure to store may be made of other natural ordering of keys, or custom ordering

Converting the set of
Java collections framework has two systems: Collection and Map, although both are essentially different, each has its own characteristics, but can be converted into a collection Map Collection set
to Map set to Collection set has three methods:
EntrySet (): returns a collection Map elements, each element includes a key and a value
KeySet (): returns a collection of all the keys Map

Working class collections
collections framework in Java also provides two auxiliary tools: Collections and Arrays
the Collections class provides a number of tools for collection Collection usual static method,
Eg: sort, copy, find, before filling and other operations, common tools static methods are as follows:
Staitc <the I> void copy (<? Super T> <? Extend T> the lIST dest, list src)
all the elements from one list to another list
Staitc <I> void fill (list <super T? > list, T obj)
replacing all of the elements specified in the list of the named element
Static <T extends Comparable <? super T> void sort (list <T> list)
according to the natural order, the specified list ascending

When using tools Colllections sort of collection, the collection element must be
Comparable comparable. A Java Comparable interface, there is a system the compareTo () method of comparing the interface.

Arrays utility class provides a variety of methods for static arrays, for example: sort, copy, search and other operations

Guess you like

Origin blog.51cto.com/14589602/2459454