Displaying the Results

Lines 21–22 call the resulting Map’s forEach method to display the summary of the results. This method receives an object that implements the BiConsumer functional interface as an argument. Recall that for Maps, the first parameter represents the key and the second represents the corresponding value. The lambda in lines 21–22 uses parameter face as the key and frequency as the value, and displays the face and frequency.

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.