9:52 am - Tuesday February 28, 2017

The unmodifiableSortedSet() method is used get an unmodifiable view of the specified sorted set.in ascending order using unmodifiableSortedSet(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 unmodifiableSortedSet() method is used get an unmodifiable view of the specified sorted set.in ascending order

Example Program


import java.util.*;

public class UnmodifySortedsetcltn {
	public static void main(String[] args) {
		// creating sortedset object
		SortedSet<String> set = new TreeSet<String>();
		// set value to treeset
		set.add("abi");

		set.add("sathi");
		set.add("karthi");
		// display the initial treeset value
		System.out.println("initial value in treeset: " + set);
		// make the treeset unmodifiable
		SortedSet<String> srtset = Collections.unmodifiableSortedSet(set);
		// try to add value to treeset
		srtset.add("subas");

	}

}



 

Explanation:

The unmodifiableSortedSet() method is used get an unmodifiable view of the specified sorted set.in ascending order

Parameter: s–This is the sorted set for which an unmodifiable view is to be returned.

 

Returns: The method call returns an unmodifiable view of the specified sorted set.

 

Throw: NA

 

BACK

Filed in: Z-A All Java Codes

Comments are closed.