Java Map remove all key value pairs

Description

Java Map remove all key value pairs

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

public class Main {
  public static void main(String[] args) {
    Map<String, String> hMap = new HashMap<String, String>();

    hMap.put("1", "CSS");
    hMap.put("2", "HTML");
    hMap.put("3", "Java");

    System.out.println(hMap);//from  ww  w .  j  av  a 2s .  c  om
    
    hMap.clear();
    
    System.out.println(hMap);
    System.out.println(hMap.size());
  }
}



PreviousNext

Related