This quick tutorial is going to show how to iterate over a HashMap in Java 8 and prior version as well. 1. Iterate Over A HashMap in Java 8 1.1. Iterate by using the forEach method of the Map interface. We can use foreach default method of the Map interface with Lambda expression to iterate over a HashMap in Java 8, for example.