Map: clear() : Map « java.util « Java by API






Map: clear()

 

import java.util.HashMap;
import java.util.Map;

public class Main {
  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();

    System.out.println(map);
  }
}

   
  








Related examples in the same category

1.implements Map
2.java.util.Map.Entry
3.Map: containsKey(Object key)
4.Map: containsValue(Object value)
5.Map: equals(Object o)
6.Map: get(Object key)
7.Map.Entry: getKey()
8.Map.Entry: getValue()
9.Map: keySet()
10.Map: put(T key, T value)
11.Map: putAll(Map m)
12.Map: remove(Object key)
13.Map: size()
14.Map: values()