HashMap and HashSet
The HashMap and HashSet classes provide two different but similar ways to organize a set of objects using the same underlying data structure.
The HashSet class is used to manage a set of objects that have unique values. Passing an object to a HashSet object's add method will add the object to the HashSet unless there is already an object in the HashSet that equals the object passed to the add method. There is also a contains method to find an object in a set and a remove method to remove an object from a set.
The HashMap class organizes objects into pairs. There are two roles in each pair. These roles are key and value. A HashMap object organizes the pairs of objects so that no two pairs have equal keys. This means that, for each key in a HashMap, there is exactly one corresponding value.
The HashMap class has a put method that is passed a key and value pair. If the key is not already in the HashMap, the pair is added to the HashMap. If the key is already present in the HashMap, the given value replaces the previous value associated with the key. There is also a get method that returns the value associated with a given key and a remove method that removes the key-value pair for a given key.
A HashMap is like a HashSet with each object in the set having an associated value. The HashSet class is implemented as a wrapper around HashMap that uses the same object for both the key and value of each object pair.
Read the Rest of this Article at Developer.com