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