Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java TreeMap Example remove()

import java.util.*;  
class Tree_Map_Remove {  
   public static void main(String args[]) {  
    TreeMap<Integer,String> map=new TreeMap<Integer,String>();    
      map.put(93,"Afghanistan");    
      map.put(213,"Algeria");    
      map.put(55,"Brazil");       
    
      System.out.println("Before remove() method");  
      for(Map.Entry mapTree:map.entrySet())  
      {  
          System.out.println(mapTree.getKey()+" "+mapTree.getValue());      
      }  
      map.remove(213);      
      System.out.println("After remove() method");  
      for(Map.Entry mapTree:map.entrySet())  
      {  
          System.out.println(mapTree.getKey()+" "+mapTree.getValue());      
      }  
      }  
}
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Java #TreeMap #Example
ADD COMMENT
Topic
Name
9+6 =