❮ Previous Next ❯

TreeMap Interface:

Let's see a program:

TreeMapDemo.java:

import java.util.*;
classTreeMapDemo
{
public static void main(String args[])
{
TreeMaphm=new TreeMap();
hm.put(100,"Tapuuu");
hm.put(102,"Silan");
hm.put(101,"Sushh");
hm.put(103,"Manu");
for(Map.Entry m:hm.entrySet())
{
System.out.println(m.getKey()+" "+m.getValue());
}
}
}

Output

100 Tapuuu
101 Sushh
102 Silan
103 Manu

HashMap vs. TreeMap:


HashMap is can contain one null key. TreeMap can not contain any null key.
HashMap maintains no order. TreeMap maintains ascending order.
❮ Previous Next ❯



  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved