How do I iterate a hash map in Java?

Learn to iterate HashMaps using forEach and Java 8’s new lambda syntax.

By Brian L. Gorman
September 16, 2016
Screenshot from "How to iterate a HashMap in Java" Screenshot from "How to iterate a HashMap in Java"

HashMaps are often considered preferable to other lookup structures due to their computational efficiency and should be a part of every Java developer’s repertoire. In this video, expert trainer Brian Gorman outlines the anatomy of a HashMap and then takes you through various methods for accessing key-value pairs from a HashMap. After watching this short tutorial, intermediate Java developers will be able to iterate HashMaps using forEach and Java 8’s new lambda syntax, while avoiding concurrent modification exceptions.

Grow your Java skills with our Mastering Java Learning Path in Safari

Learn faster. Dig deeper. See farther.

Join the O'Reilly online learning platform. Get a free trial today and find answers on the fly, or master something new and useful.

Learn more

Brian L. Gorman is an experienced .NET developer, certified as an MCSD in C# .NET. Holding a Masters of Science in computer information systems, he has many years of experience instructing college-level SQL database, C#, VB.NET, Java, and Microsoft Office courses. Brian has also authored a number of full technical video courses on these subjects.

Post topics: Software Engineering
Post tags: Questions
Share: