Source Code : The NavigableMap Interface

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

The NavigableMap Interface

 

The java.util.NavigableMap interface, a new addition to Java 6, inherits SortedMap to add navigation methods that allows for key/value pair searching.

The java.util.TreeMap class in Java 6 implements NavigableMap. 

import java.util.NavigableMap;
import java.util.TreeMap;
import java.util.Map.Entry;

public class NavigableMapDemo {
  public static void main(String[] args) {
    NavigableMap<Integer, String> map = new TreeMap<Integer, String>();
    map.put(2, "two");
    map.put(1, "one");
    map.put(3, "three");
    System.out.println("Original map: " + map + "
");

    Entry firstEntry = map.pollFirstEntry();
    System.out.println("First entry: " + firstEntry);
    System.out.println("After polling the first entry: " + map + "
");

    Entry lastEntry = map.pollLastEntry();
    System.out.println("Last entry:" + lastEntry);
    System.out.println("After polling last entry:" + map);
  }
}

/*Original map: {1=one, 2=two, 3=three}

First entry: 1=one
After polling the first entry: {2=two, 3=three}

Last entry:3=three
After polling last entry:{2=two}
*/

        

Thank with us