Thursday, May 5, 2022

Question 4: Given a list of employee, find maximum age of employee?

Answer:
It is again very simple logic, change the main function in above class as following

 
List<Employee> employeeList = createEmployeeList(); OptionalInt max = employeeList.stream(). mapToInt(Employee::getAge).max(); if(max.isPresent()) System.out.println("Maximum age of Employee: "+max.getAsInt());

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