Compare values of elements in Stream
Your code and Java 8 usage looks fine in general to me.

I do see an issue with the Person class, it looks like you are intending it to be an immutable class, if so, then you should also enforce it.

You need to ensure that the name and id fields can never be changed, you can do this by adding final to them. Your code currently seems to be safe, but it is not. I can extend Person and offer a method there to change the name and id fields, which violates the assumed variant of that those fields in Person are immutable.

Simply changing it to the following will do:

public class Person {
    private final String name;
    private final String id;
    ...
}


Onto the Java 8 usage now.

It is a good thing that you use the Collectors.groupingBy to provide a Map&lt;String, List&lt;Person&gt;&gt;, you cannot do it much faster either way if you want it to work with any kind of List&lt;Person&gt; as input and in this way you'll save yourself from nasty bugs and reimplementing what lots of people have already done, namely the grouping by operation.

Printing the offending values using Stream seems fine as well, except that you may rewrite it to look a little bit cleaner, something like this could work:

peopleById.values().stream()
    .filter(personList -&gt; personList.size() &gt; 1)
    .forEach(personList -&gt; System.out.println("People with identical IDs: " + personList);


This is my personal preference on how to format it though, the only real change is to rename peopleWithSameId to personList, as it is simply a List&lt;Person&gt; and nothing more or less.

You've done a good job overall.