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

Follow on LinkedIn

You may also like

Kubernetes AWS Java Coding Question
Microservices Core Java Spring Boot
Spring Framework Kafka Miscellaneous