Q:

Java Program to remove element with key in this map

0

Program to remove element with key in this map

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.*;  
public class demo1
 {  
  public static void main(String args[])
  {  
   TreeMap<Integer,String> treemap=new TreeMap<Integer,String>();      
   treemap.put(1, "C#");
   treemap.put(2, "C++");
   treemap.put(3, "Java");
   treemap.put(4, "Python");
   treemap.put(5, "Perl");

   System.out.println("Elements in treemap are: " + treemap);
   treemap.remove(3);
   System.out.println("Treemap after removing element: " + treemap);
 }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now