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