3:11 pm - Tuesday November 23, 2776

Return a view of the portion of this map headMap(K toKey, boolean inclusive)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK 

    This tutorial explains how  to Return a view of the portion of this map using headMap(K toKey,

    boolean inclusive) method.inclusive–This is true if the high endpoint is to be included in the returned view.

Example

import java.util.TreeMap;
import java.util.Map.Entry;
public class TreeMapHeadmap
{
public static void main(String[] args)

{
   TreeMap<Integer, String> treemap = new TreeMap<Integer, String>();
   NavigableMap<Integer, String> treemapheadincl = new TreeMap<Integer, String>();
   treemap.put(2, "two");
   treemap.put(1, "one");
   treemap.put(3, "three");
   treemap.put(6, "six");
   treemap.put(5, "five");
   treemapheadincl=treemap.headMap(3,true);
   System.out.println("Checking values of the map");
   System.out.println("Value is: "+ treemapheadincl);
 }
}

Output 

              Checking values of the map

              Value is: {1=one, 2=two, 3=three}

 

BACK

Filed in: Java Examples

Comments are closed.