Java Map get size

Description

Java Map get size

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>();

    System.out.println("Size of HashMap : " + hMap.size());

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

    System.out.println("Size of HashMap after addition : " + hMap.size());

    // remove one element from HashMap
    System.out.println(hMap.remove("2"));
    //from www.  ja  v  a  2  s  .c o  m
    System.out.println("Size of HashMap after deleting : " + hMap.size());

  }
}



PreviousNext

Related