HashMap entrySet() Method in Java
The entrySet() method of HashMap returns the set view of the entries in this map.
Syntax
Set> entrySet()
Parameters
It does not take any parameters.
Return Value
It returns the set of entries
Program
import java.util.HashMap;
import java.util.Map;
public class HashMapEntrySetExample {
public static void main(String[] args) {
Map map = new HashMap();
map.put(101, "John");
map.put(102, "Adam");
map.put(103, "Ricky");
map.put(104, "Chris");
System.out.println("Key-Value entries in map: " + map.entrySet());
}
}
Output
Key-Value entries in map: [101=John, 102=Adam, 103=Ricky, 104=Chris]
0 Comments