Java

Program to create a new Tree Map with the specified key.

Program to create a new Tree Map with the specified key.
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");
    
   for (Map.Entry<Integer,String> entry : treemap.entrySet())
   {
    System.out.println(entry.getKey() +"="+ entry.getValue());
   }
 }  
}
Nikhil Juneja

Passionate software developer and technical contributor at TutorialsLink.