javajava-8java-streamtostring

Why is it returning address instead of object?


Comparator<Employee> comparator =Comparator.comparing(Employee::getIncome);
Employee minObj= Employee.persons().stream()
                       .min(comparator)
                       .get();

This is returning me address instead of an object.

toMap.Employee@66133adc

What is the problem and how to write it correctly?


Solution

  • It probably isn't—you have forgotten to override toString().