Javatpoint Logo
Javatpoint Logo

Java Collections synchronizedCollection() Method

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

Syntax

Following is the declaration of synchronizedCollection() method:

Parameter

Parameter Description Required/Optional
c It is the collection to be "wrapped" in a synchronized collection. Required

Returns

The synchronizedCollection() method returns a synchronized view of the specified collection.

Exceptions

NA

Compatibility Version

Java 1.5 and above

Example 1

Test it Now

Output:

Synchronized view is :[A, B, C, D, E]

Example 2

Test it Now

Output:

Synchronized view is :[44, 55, 99, 77, 88, 66]

Example 3

Test it Now

Output:

JavaTpoint
SSSIT
JavaTpoint
SSSIT






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA