80
Java Collections synchronizedSortedMap() Method
The synchronizedSortedMap() method of Java Collections class is used to get a synchronized (thread-safe) sorted map backed by the specified sorted map.
Syntax
Following is the declaration of synchronizedSortedMap() method:
Parameter
Parameter | Description | Required/Optional |
---|---|---|
m | It is the sorted map which will be wrapped in a synchronized sorted map. | Required |
Returns
The synchronizedSortedMap() method returns a synchronized view of the specified sorted Map.
Exceptions
NA
Example 1
Output:
Synchronized sorted map is :{1=Whatsapp, 2=Twitter, 3=Facebook, 4=Instagram}
Example 2
Output:
Synchronized sorted map:{1=1001, 2=1002, 3=1003, 4=1004, 5=1005}
Example 3
Output:
10
Next TopicJava Collections Class