Thursday, May 5, 2022

Question 3: Given the list of employees, find the employee with name “Mary”.

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

List<Employee> employeeList = createEmployeeList(); Optional<Employee> e1 = employeeList.stream() .filter(e->e.getName().equalsIgnoreCase("Mary")).findAny(); if(e1.isPresent()) System.out.println(e1.get());


 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