JavaBeat Certifications Certifications Kits Articles Interview Questions OCAJP 7 OCPJP 5 OCPJP 6 OCEJWCD 6 SCBCD 5.0 SCEA SCJA
400 Mock Questions on OCPJP 6 (formerly known as SCJP 1.6)
JUST Rs.300 or 10 USD Send us mail to sales@javabeat.net
more details
Do you have paypal account? Click Here to pay now and get the questions.

NavigableMap in Java 6.0

by JavaBeat(08/12/2007)

NavigableMap is similar to NavigableSet. In NavigableMap we will use key value pairs to reterive the value. see the following code:


navigableMap.put(1,"tiger");
Look into the following code snippet:

package javabeat.net;

import java.util.NavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;

public class NavigableMapExample1 {
    public static void main(String args[]){
        NavigableMap<Integer,String> navigableMap = new ConcurrentSkipListMap<Integer,String>();
        navigableMap.put(1,"tiger");
        navigableMap.put(2,"lion");
        navigableMap.put(3,"leopard");
        System.out.println(navigableMap.lowerEntry(2));
        System.out.println(navigableMap.higherEntry(2));
    }
}

In tha bove code NavigableMap API is used for reteriving the less than and greater than value based on key. The output would be like this:


1=tiger
3=leopard
400 Mock Questions on OCPJP 6 (formerly known as SCJP 1.6)
JUST Rs.300 or 10 USD Send us mail to sales@javabeat.net
more details

javabeat | advertise | about us | contact | useful resources
Copyright (2004 - 2013), JavaBeat