12:41 am - Monday August 21, 2017

This Program is used to get a dynamically typesafe view of the specified sorted map using checkedSortedMap(SortedMap<, V>, Class, Class)

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 Program is used to get a dynamically typesafe view of the specified sorted map using checkedSortedMap(SortedMap<, V>, Class<K>, Class<V>)

Example Program


import java.util.*;

public class CollectionsDemo {
public static void main(String args[]) {
// create sorted map
SortedMap smap = new TreeMap();

// populate the map
smap.put(“1″, “Only”);
smap.put(“2″, “tutorials”);
smap.put(“3″, “point”);

// get typesafe view of the sorted map
SortedMap tsmap;

tsmap = Collections.checkedSortedMap(smap, String.class, String.class);

System.out.println(“Typesafe view of the sorted map: ” + tsmap);
}
}

[/java[

 

Output:

Typesafe view of the sorted map: {1=Only, 2=tutorials, 3=point}

Description:

       The checkedSortedMap(SortedMap<, V>, Class<K>, Class<V>) method is used to get a dynamically   typesafe view of the specified sorted map.

 

Declaration:

public static <K,V> SortedMap<K,V> checkedSortedMap(SortedMap<K,V> m,Class<K> keyType,Class<V> valueType)

Parameters:

  • m–This is the map for which a dynamically typesafe view is to be returned.

  • keyType–This is the type of key that m is permitted to hold.

  • valueType –This is the type of value that m is permitted to hold.

Return Value:

The method call returns a dynamically typesafe view of the specified map

 

Exception:

NA

BACK

Filed in: Z-A All Java Codes

Comments are closed.