127
Java Collections synchronizedNavigableSet() Method
The synchronizedNavigableSet() method of Java Collections class is used to get a synchronized (thread-safe) navigable set backed by the specified navigable set.
Syntax
Following is the declaration of synchronizedNavigableSet() method:
Parameter
Parameter | Description | Required/Optional |
---|---|---|
s | It is the navigable set which will be wrapped in a synchronized navigable set. | Required |
Returns
The synchronizedNavigableSet() method returns a synchronized view of the specified Navigable Set.
Exceptions
NA
Compatibility Version
Java 1.8 and above
Example 1
Output:
Synchronized navigable set is :[Facebook, Google, Instagram, TutorAspire ]
Example 2
Output:
Set before Synchronized navigable set: [1001, 1002, 1003, 1004, 1005] Synchronized navigable set after remove(1004):[1001, 1002, 1003, 1005]
Example 3
Output:
1000
Example 4
Output:
Set before Synchronized navigable set: [1001, 1002, 1003, 1004, 1005] Set after Synchronized navigable set- 1001 1002 1003 1004 1005
Next TopicJava Collections Class