Thursday, May 5, 2022

Question 2: Given the list of employees, count number of employees with age 25?

 Answer:
You can use combination of filter and count to find this.
List<Employee> employeeList = createEmployeeList(); long count = employeeList.stream() .filter(e->e.getAge()>25) .count();
System.out.println("Number of employees with age 25 are : "+count);

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