Menu
Topics Index
...
`

NavigableMapDemo - Java Example Program


NavigableMapDemo
import java.util.*;

class NavigableMapDemo
{
    public static void main(String arg[])
    {
        TreeMap<String, String> tm = new TreeMap<String, String>();
        tm.put("S", "Sachin");
        tm.put("D", "Dhoni");
        tm.put("Y", "Yuvi");
        tm.put("G", "Ganguly");
        tm.put("K", "Kohli");
        System.out.println(tm);
        System.out.println(tm.ceilingKey("D"));
        System.out.println(tm.higherKey("E"));
        System.out.println(tm.floorKey("E"));
        System.out.println(tm.lowerKey("E"));
        System.out.println(tm.pollFirstEntry());
        System.out.println(tm.pollLastEntry());
        System.out.println(tm.descendingMap());
        System.out.println(tm);    
    }
}
OUTPUT

{D=Dhoni, G=Ganguly, K=Kohli, S=Sachin, Y=Yuvi}
D
G
D
D
D=Dhoni
Y=Yuvi
{S=Sachin, K=Kohli, G=Ganguly}
{G=Ganguly, K=Kohli, S=Sachin}

DESCRIPTION

© meritcampus 2019

All Rights Reserved.

Open In App