805 OCPJP 6 Questions 788 SCJP 5 questions 650 OCPJWCD 5 questions 600 OCAJP 7 questions 610 OCPJP 7 questions 510 Upgrade to OCPJP 7 questions 900 Java J2EE Qns

Tutorials

SCJP : NavigableMap

public interface NavigableMap
extends SortedMap
A SortedMap extended with navigation methods returning the closest matches for given search targets.


A NavigableMap may be accessed and traversed in either ascending or descending key order.


This interface additionally defines methods firstEntry, pollFirstEntry, lastEntry, and pollLastEntry that return and/or remove the least and greatest mappings, if any exist, else returning null.


NavigableMap use key value pairs to put the value.
import java.util.NavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;


public class Test {

public static void main(String... args) {
        
		
		NavigableMap navMap = new ConcurrentSkipListMap();
		
		navMap.put(4, "April");
		navMap.put(5, "May");
		navMap.put(6, "June");
		navMap.put(1, "January");
		navMap.put(2, "February");
		navMap.put(3, "March");

        System.out.print(navMap.firstEntry());
        System.out.print(navMap.lastEntry());
        System.out.print(navMap.get(6));


	     	      
	}
}
					
The output:
1=January
6=June
June			
					
scjp 1.5 | scjp 1.6 | scwcd 1.5
Java Certifications
www.javacertifications.net