Thursday, May 5, 2022

Question 6 :Join the all employee names with “,” using java 8?


List<Employee> employeeList = createEmployeeList(); List<String> employeeNames = employeeList .stream() .map(Employee::getName) .collect(Collectors.toList()); String employeeNamesStr = String.join(",", employeeNames); System.out.println("Employees are: "+employeeNamesStr);

Output:

Employees are: John,Martin,Mary,Stephan,Gary
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