Get Size of LinkedHashMap - Java Collection Framework

Java examples for Collection Framework:LinkedHashMap

Description

Get Size of LinkedHashMap

Demo Code



import java.util.LinkedHashMap;
 
public class Main {
 
  public static void main(String[] args) {
    LinkedHashMap lHashMap = new LinkedHashMap();
    System.out.println("Size of LinkedHashMap : " + lHashMap.size());
   //from w ww .  j ava2  s . co  m
    lHashMap.put("1","One");
    lHashMap.put("2","Two");
    lHashMap.put("3","Three");
    System.out.println("Size of LinkedHashMap after addition : " + lHashMap.size());
   
    Object obj = lHashMap.remove("2");
    System.out.println("Size of LinkedHashMap after removal : " + lHashMap.size());
  }
}

Result


Related Tutorials