Since the toString is implemented for the instances of Person class, you shall invoke println over the objects of Person type instead of mapping them to their name and then printing the String type.

So something as simple as

stream.forEach(System.out::println);

shall give you the desired output "Java".

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top