❮ HashMap Methods
forEach()Definition and Usage
The forEach() method performs an action on every entry in the map. The action can be defined by a lambda expression that is compatible with the accept() method of Java's BiConsumer interface.
To learn about lambda expressions, see our Java Lambda Expression tutorial .
Syntax
public void forEach(BiConsumer
action )Parameter Values
| Parameter | Description |
|---|---|
| action | Required. A BiConsumer object or lambda expression which performs an action on an entry. The first parameter contains the key of an entry and the second parameter contains its value. |