Get navigableKeySet in Java NavigableMap Example

Get navigableKeySet in Java NavigableMap Example


Posted in : Java Posted on : December 8, 2010 at 5:57 PM Comments : [ 0 ]

This Java Example shows how to Get navigableKeySet in Java NavigableMap object.

Get navigableKeySet() in Java NavigableMap Example

This Java Example shows how to Get navigableKeySet in Java NavigableMap object. To get an navigableKeySet of NavigableMap We use NavigableSet   navigableKeySet() method. This method returns a NavigableSet view of the keys contained in this map.

 Example: NavigableKeySetNavigableMap.java

package devmanuals.com;

import java.util.*;

public class NavigableKeySetNavigableMap {
	public static void main(String[] args) {
		NavigableMap<Integer, String> Nmap = new TreeMap<Integer, String>();
		Nmap.put(2, "two");
		Nmap.put(1, "one");
		Nmap.put(3, "three");
		Nmap.put(6, "six");
		Nmap.put(5, "five");
		System.out.println("The Map entry are : " + Nmap);
		System.out.println("The NavigableMap key set is : "
				+ Nmap.navigableKeySet());

	}
}

Output:

The Map entry are : {1=one, 2=two, 3=three, 5=five, 6=six} 

The NavigableMap key set is : [1, 2, 3, 5, 6]

Download The Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics