5:54 am - Thursday August 17, 2017

The SortedSet interface extends Set and declares the behavior of a set sorted in ascending order using synchronizedSortedSet(SortedSet s)

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

The SortedSet interface extends Set and declares the behavior of a set sorted in ascending order. In addition to those methods defined by Set, the SortedSet interface declares the methods summarized in below Table.The synchronizedSortedSet() method is used to get a synchronized (thread-safe) sorted set backed by the specified sorted set.

Example Program

import java.util.Collections;
import java.util.SortedSet;
import java.util.TreeSet;

public class SynchronizedShortedtst {
	public static void main(String[] args) {
		// create the set
		SortedSet set = new TreeSet();
		// populate the set
		set.add("sivan");
		set.add("kannan");
		set.add("sathi");
		set.add("karthi");
		// create synchronized sorted test
		SortedSet sorset = Collections.synchronizedSortedSet(set);
		System.out.println("sorted set is: " + sorset);

	}

}

Output:

sorted set is: [kannan, karthi, sathi, si]

Parameters: s–This is thethe sorted set to be “wrapped” in a synchronized sorted set.

Returns:  The method call returns a synchronized view of the specified sorted set.        

Throws: NA

 

 

BACK

Filed in: Z-A All Java Codes

Comments are closed.