Javatpoint Logo
Javatpoint Logo

Java ConcurrentHashMap keySet() Method

The keySet() method of ConcurrentHashMap class returns a Set view of the keys contained in this map. The set is stacked by the map, so changes to the map are reflected in the set, and vice-versa.

Syntax

Parameter

No parameter is passed.

Returns

the set view

Throws

No Exception is thrown.

Example 1

Test it Now

Output:

Map : {20=php, 10=Java, 11=.net, 12=C, 30=C++}
keySet : [20, 10, 11, 12, 30]

Example 2

Test it Now

Output:

Using KeySet : [A, B, C, D, E]
 enumeration of keys are:
A
B
C
D
E





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