Remove all values from TreeMap - Java Collection Framework

Java examples for Collection Framework:TreeMap

Description

Remove all values from TreeMap

Demo Code

 
import java.util.TreeMap;
 
public class Main {
 
  public static void main(String[] args) {
    TreeMap treeMap = new TreeMap();
   // www  .  j  a v  a2 s .  c o  m
    //add key value pairs to TreeMap
    treeMap.put("1","One");
    treeMap.put("2","Two");
    treeMap.put("3","Three");
 
    treeMap.clear();
   
    System.out.println("Total key value pairs in TreeMap are : " + treeMap.size());
  }
}

Result


Related Tutorials