“Contoh Java Treemap” Kode Jawaban

Java treemap contoh navigablemap

import java.util.*;  
class Navigable_Tree_Map{  
public static void main(String args[]){  
   NavigableMap<Integer,String> map=new TreeMap<Integer,String>();    
      map.put(93,"Afghanistan");    
      map.put(213,"Algeria");    
      map.put(55,"Brazil");    
      map.put(33,"France"); 
      map.put(49,"Germany"); 
      map.put(354,"Iceland"); 
     
      System.out.println("Navigable Map in Decending Order: "+map.descendingMap());  
  
      System.out.println("Navigable Map using headMap() method: "+map.headMap(49,true));  
  
      System.out.println("Navigable Map using tailMap() method: "+map.tailMap(49,true));
 
      System.out.println("Navigable Map using subMap() method: "+map.subMap(33, false, 55, true));   
}  
}
Outrageous Ostrich

Contoh Java Treemap

import java.util.*;  
class Tree_Map{  
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");       
        
      for(Map.Entry mapTree:map.entrySet()){    
       System.out.println(mapTree.getKey()+" "+mapTree.getValue());    
      }    
}  
}
Unsightly Unicorn

Jawaban yang mirip dengan “Contoh Java Treemap”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya