How to find highest salary employee using Java 8 stream API |

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024
  • How to find the employee which is having highest salary in the organization ?
    Print the employee which is having maximum salary using java8 stream API?
    Java8 stream API sorted method
    Hello All,
    In this video we will see how to find highest salary employee in the organization using java 8 stream API?
    Employee employee = empList.stream().sorted(Comparator.comparing(Employee::getSalary).reversed()).findFirst().get();
    System.out.println(" Highest salary employee is : "+employee);
    #javainterviewquestions #interviewquestions #preparation #java8stream

Комментарии • 2

  • @svltejaswi
    @svltejaswi 4 месяца назад

    How to find second highest salary employee??findFirst only finds highest