List of usage examples for java.util Map put
V put(K key, V value);
From source file:Main.java
public static void main(String[] a) { Map<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); System.out.println(map);/* www . ja v a2s .c om*/ }
From source file:Main.java
public static void main(String[] args) { Map<String, String> map = new HashMap<>(); map.put("CSS", "style"); map.put("HTML", "mark up"); map.put("Oracle", "database"); map.put("XML", "data"); printDetails(map);//from w ww . jav a 2s.co m map.clear(); printDetails(map); }
From source file:Main.java
public static void main(String[] a) { Map<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); System.out.println(map);/*from ww w.j av a2 s . c o m*/ }
From source file:Main.java
public static void main(String[] argv) { Map<Number, String> numMap = new HashMap<Number, String>(); numMap.put(.5, "half"); numMap.put(1, "first"); }
From source file:Main.java
public static void main(String[] a) { Map<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); System.out.println(map.get("key2")); }
From source file:Main.java
public static void main(String[] a) { Map<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); map.clear();//from ww w.jav a 2 s. c o m System.out.println(map.isEmpty()); }
From source file:Main.java
public static void main(String[] a) { Map<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); map.clear();// www. ja va 2s .c om System.out.println(map); }
From source file:Main.java
public static void main(String[] a) { Map<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); System.out.println(map.containsKey("key1")); System.out.println(map.containsValue("value2")); }
From source file:Main.java
public static void main(String[] a) { Map<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); map.clear();/*from w w w. j a v a 2 s . c o m*/ System.out.println(map.hashCode()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Map<Integer, String> map = new HashMap<Integer, String>(); map.put(1, "first"); map.put(2, "second"); // map.put(1, 2); <- Syntax error }