Home » Java Collections synchronizedSortedSet() Method with Examples

Java Collections synchronizedSortedSet() Method with Examples

by Online Tutorials Library

Java Collections synchronizedSortedSet() Method

The synchronizedSortedSet() method of Java Collections class is used to get a synchronized (thread-safe) sorted set backed by the specified sorted set.

Syntax

Following is the declaration of synchronizedSortedSet() method:

Parameter

Parameter Description Required/Optional
s It is the sorted set which will be wrapped in a synchronized sorted set. Required

Returns

The synchronizedSortedSet() method returns a synchronized view of the specified Sorted Set.

Exceptions

NA

Example 1

Test it Now

Output:

Synchronized Sorted set is :[Facebook, Instagram, Twitter, Whatsapp]  

Example 2

Test it Now

Output:

Set after Synchronized sorted set-  101  102  103  104  105  

Example 3

Test it Now

Output:

1000  

You may also like