HashMap in Java

A HashMap store items in "key/value" pairs, and you can access them by an index of different type (e.g. a String).
It is thread-safe and can be shared with many threads. HashMap allows one null key and multiple null values whereas Hashtable doesn't allow any null key or value. HashMap is generally preferred over HashTable if thread synchronization is not needed.
```
import java.util.*;
public class A {
    public static void main(String[] args) {
        Map<O, String> m = new HashMap<O, String>();
        m.put(new O("Java"), "java");
        m.put(new O("C++"), "cpp");
        System.out.println(m.get(new O("Java")));
    }
}

class O {
    String name;
    O(String n) { name = n; }
}
```