VOOZH about

URL: https://www.geeksforgeeks.org/java/concurrenthashmap-keys-method-in-java-with-examples/

⇱ ConcurrentHashMap keys() method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

ConcurrentHashMap keys() method in Java with Examples

Last Updated : 30 Oct, 2018
The keys() method of ConcurrentHashMap class in Java is used to get the enumeration of the keys present in the hashmap. Syntax:
Enumeration enu = ConcurrentHashMap.keys()
Parameters: The method does not take any parameters. Return value: The method returns an enumeration of the keys of the ConcurrentHashMap. Below programs are used to illustrate the working of the keys() method: Program 1:
Output:
The Map is: {20=Geeks, 25=Welcomes, 10=Geeks, 30=You, 15=4}
The enumeration of keys are:
20
25
10
30
15
Program 2:
Output:
The Map is: {4=15, Geeks=20, You=30, Welcomes=25}
The enumeration of keys are:
4
Geeks
You
Welcomes
Comment