Hash Map


import java.util.HashMap;

public class HashMapDemo 
{
    public static void main(String[] args
    {
        HashMap<Integer,String> map=new HashMap<Integer, String>()// defines type of key and values
        map.put(1"aaaa");   // adds elements to hashmap as key-value pairs.
        map.put(2"bbbb");
        
        System.out.println("Value at index 1: "+map.get(1));     // gets the value from Hashmap specifying the index.
        
    }
}

Output:
Value at index 1: aaaa