Listing 8: PollsNMDemo.java
import java.util.*;
public class PollsNMDemo{
public static void main(String args[]) {
//create a SortedMap -> tree structure
SortedMap SM=new TreeMap();
//create a NavigableMap
NavigableMap NM=(NavigableMap)(SM);
//populate the NM
NM.put(8.09,"Hydro");
NM.put(7.25,"George");
NM.put(9.00,"Any");
NM.put(10.00,"Martin");
NM.put(5.64,"Wallace");
Double test=new Double(9.0);
//firstEntry
System.out.println("----------------------------------------");
Map.Entry<Double,String> first_entry=NM.firstEntry();
System.out.println("first_entry:{"+first_entry.getKey()+","+first_entry.getValue()+"}");
System.out.println("----------------------------------------");
//lastEntry
System.out.println("----------------------------------------");
Map.Entry<Double,String> last_entry=NM.lastEntry();
System.out.println("last_entry:{"+last_entry.getKey()+","+last_entry.getValue()+"}");
System.out.println("----------------------------------------");
//pollFirstEntry
System.out.println("----------------------------------------");
Map.Entry<Double,String> poll_first_entry=NM.pollFirstEntry();
System.out.println("pool_first_entry:{"+poll_first_entry.getKey()+","
+poll_first_entry.getValue()+"}");
System.out.println("----------------------------------------");
//firstEntry - this method will return now the entry: {7.25,George}
//pollLastEntry
System.out.println("----------------------------------------");
Map.Entry<Double,String> poll_last_entry=NM.pollLastEntry();
System.out.println("pool_last_entry:{"+poll_last_entry.getKey()+",
"+poll_last_entry.getValue()+"}");
System.out.println("----------------------------------------");
//lastEntry - this method will return now the entry: {9.0,Any}
}
}
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|