Home » Java Collections synchronizedSortedMap() Method with Examples

Java Collections synchronizedSortedMap() Method with Examples

by Online Tutorials Library

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

Test it Now

Output:

Synchronized sorted map is :{1=Whatsapp, 2=Twitter, 3=Facebook, 4=Instagram}  

Example 2

Test it Now

Output:

Synchronized sorted map:{1=1001, 2=1002, 3=1003, 4=1004, 5=1005}  

Example 3

Test it Now

Output:

10  

You may also like