Count how many times a value is referenced in a grid
There is no intermediate operation that groups items by key.

But in your example there are some changes that can make code more readable.


Instead of collectiing to Map&lt;Double, List&lt;Point&gt;&gt; you could collect directly to Map&lt;Double, Long&gt;

.collect(groupingBy(p -&gt;  pointGrid.get(p.x, p.y), counting()))

Instead of creating stream and performing output just use forEach on a map

.forEach((value, count) -&gt; System.out.println("value :" + value + " count: " + count);



So together it looks like

seedPoints.stream()
    .collect(groupingBy(p -&gt;  pointGrid.get(p.x, p.y), counting()))
    .forEach((value, count) -&gt; System.out.println("value :" + value + " count: " + count);