Listing 11: head_sub_tail_NM_Demo.java
import java.util.*;
    
    public class head_sub_tail_NM_Demo{
    
        public static void seeEntries(SortedMap SM,String info)
            {
            //see the entries  
            System.out.println(info);              
            Iterator i=SM.keySet().iterator();
            while(i.hasNext()){
                Double key=(Double)i.next(); 
                            System.out.println("Name:"+SM.get(key)+"\tNote:"+key); 
            }           
           }       
        
        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);
          
            //headMap - exclusive
            System.out.println("----------------------------------------");                    
            SortedMap SMheadMapE=NM.headMap(9.0);            
            seeEntries(SMheadMapE,"headMap exclusive:");            
            System.out.println("----------------------------------------"); 
          
            //headMap - inclusive
            System.out.println("----------------------------------------");                    
            SortedMap SMheadMapI=NM.headMap(9.0,true);            
            seeEntries(SMheadMapI,"headMap inclusive:");            
            System.out.println("----------------------------------------"); 
         
            //subMap - (inclusive,exclusive) 
            System.out.println("----------------------------------------");                    
            SortedMap SMsubMapIE=NM.subMap(7.25,9.0);            
            seeEntries(SMsubMapIE,"subMap (inclusive,exclusive):");            
            System.out.println("----------------------------------------"); 

            //subMap - (inclusive,inclusive) 
            System.out.println("----------------------------------------");                    
            SortedMap SMsubMapII=NM.subMap(7.25,true,9.0,true);            
            seeEntries(SMsubMapII,"subMap (inclusive,inclusive):");            
            System.out.println("----------------------------------------"); 

            //subMap - (exclusive,exclusive) 
            System.out.println("----------------------------------------");                    
            SortedMap SMsubMapEE=NM.subMap(7.25,false,9.0,false);            
            seeEntries(SMsubMapEE,"subMap (exclusive,exclusive):");            
            System.out.println("----------------------------------------"); 

            //subMap - (exclusive,inclusive) 
            System.out.println("----------------------------------------");                    
            SortedMap SMsubMapEI=NM.subMap(7.25,false,9.0,true);            
            seeEntries(SMsubMapEI,"subMap (exclusive,inclusive):");            
            System.out.println("----------------------------------------"); 

           //tailMap - inclusive
            System.out.println("----------------------------------------");                    
            SortedMap SMtailMapI=NM.tailMap(9.0);            
            seeEntries(SMtailMapI,"tailMap inclusive:");            
            System.out.println("----------------------------------------"); 
          
            //tailMap - exclusive
            System.out.println("----------------------------------------");                    
            SortedMap SMtailMapE=NM.tailMap(9.0,false);            
            seeEntries(SMtailMapE,"tailMap exclusive:");            
            System.out.println("----------------------------------------"); 
            }
    }

How to Add Java Applets to Your Site

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.