12:13 pm - Sunday June 25, 2017

This Program is used to get a dynamically typesafe view of the specified sorted set using checkedSortedSet(SortedSet, Class) method.

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 set using checkedSortedSet(SortedSet<E>, Class<E>) method.

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);
	}
}

 

Output:

Dynamically typesafe view: [Java, best, is]

Description:

The checkedSortedSet(SortedSet<E>, Class<E>) method is used to get a dynamically typesafe view of the specified sorted set.

Declaration:

public static <E> SortedSet<E> checkedSortedSet(SortedSet<E> s, Class<E> type)

Parameters:

  • s–This is the sorted set for which a dynamically typesafe view is to be returned.

  • type–This is the type of element that s is permitted to hold.

Return Value:

The method call returns a dynamically typesafe view of the specified sorted set.

 

Exception:

NA

BACK

 

Filed in: Z-A All Java Codes

Comments are closed.