2dbi

Find maximum salary from a list of Employee objects using Java Streams

via2dbi

Problem

Given a list of Employee POJOs, find the maximum salary using Java Streams only.

Example

employees.stream()
         .mapToInt(Employee::getSalary)
         .max();

Notes

  • Must use the Streams API (no manual loops)
  • Discuss Optional handling for an empty list
Add a follow-up question they asked
Handle the empty list
Top salary per department
asked …
LeaderboardSalary
Language
Account