map.put in java code example
Example 1: map.put in java
import java.util.*;
public HashMap{
public static void main(String[] args){
Map map = new HashMap<>();//initialization of HashMap
map.put(key, value);//key and value must be entered
System.out.println(map);
}
}
Example 2: java add element to map
map.put(key, Object);
//exemple:
Map map = new HashMap();
map.put("mykey", "myvalue");