In this example we will show the method to create a HashMap in Java.
Source Code
package com.beginner.examples;
import java.util.HashMap;
public class CreateHashMap {
public static void main(String[] args) {
HashMap h = new HashMap(); // create a HashMap
h.put("A", "a");
h.put("B", "b");
System.out.println(h);
}
}
Output:
{A=a, B=b}
References
Imported packages in Java documentation: