9.26.1.HashMap Class: a basic key-value map where the elements are unorderedPrevious/Next
A Map is a storage that hold key to value mappings.
There cannot be duplicate keys in a Map and each key maps to at most one value.
HashMap is unsynchronized and Hashtable is synchronized.
HashMap is the faster one between the two.
If you need to maintain map keys in an ordered fashion, you can use TreeMap.
Creating a HashMap
public HashMap() public HashMap(int initialCapacity) public HashMap(int initialCapacity, float loadFactor)
The fourth constructor is the standard copy constructor, which creates a new HashMap from another map:
public HashMap(Map map)
HashMap Class: a basic key-value map where the elements are unordered