Java Adicionar elemento ao mapa
map.put(key, Object);
//exemple:
Map<String, String> map = new HashMap<String, String>();
map.put("mykey", "myvalue");
map.put(key, Object);
//exemple:
Map<String, String> map = new HashMap<String, String>();
map.put("mykey", "myvalue");
Map<String, String> map = new HashMap<String, String>(); // Make an empty map
map.put("es", "Spain"); // Add the key/value pairs
map.put("us", "United States");
map.put("zw", "Zimbabwe");
import java.util.*;
public HashMap{
public static void main(String[] args){
Map<Integer, String> map = new HashMap<>();//initialization of HashMap
map.put(key, value);//key and value must be entered
System.out.println(map);
}
}