Thursday, May 5, 2022

Question 5: Given a list of employees, sort all the employee on the basis of age? Use java 8 APIs only

 You can simply use sort method of list to sort the list of employees.

List<Employee> employeeList = createEmployeeList(); employeeList.sort((e1,e2)->e1.getAge()-e2.getAge()); employeeList.forEach(System.out::println);

Don't miss the next article! 
Be the first to be notified when a new article or Kubernetes experiment is published.                            

   Share This

You may also like

Kubernetes Microservices
Python AI/ML
Spring Framework Spring Boot
Core Java Java Coding Question
Maven AWS