Hash Table
import java.util.Hashtable;
public class HashTableDemo
{
public static void main(String[] args)
{
Hashtable<Integer,String> h=new Hashtable<Integer, String>(); // defines type of key and values
h.put(1, "aaaa"); // adds elements to hashtable as key-value pairs.
h.put(2, "bbbb");
System.out.println("Value at index 1: "+h.get(1)); // gets the value from Hashtable specifying the index.
}
}
Output:
Value at index 1: aaaa