Since the toString is implemented for the instances of Person
class, you shall invoke println
over the objects of Person
type instead of map
ping 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.