Webcam Chat QuickBooks Advice international calling cards international phone cards
JavaBeat Certifications Certifications Kits Articles Tutorials Tips QNA Book Store Interview Questions SCJP 1.5 SCJP 1.6 SCWCD 5.0 SCBCD 5.0 SCEA SCJA Feeds
Kaspersky Anti-Virus 2011
400 Mock Questions on 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 SCJP 1.6 - JUST Rs.300 or 10 USD
Send us mail to sales@javabeat.net
more details

JavaBeat Website (2004-2009), India
javabeat | advertise | about us | useful resources
Copyright (2004 - 2009), JavaBeat