“Exemple Java Treemap” Réponses codées

Java Treemap Exemple 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

Exemple 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

Réponses similaires à “Exemple Java Treemap”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code