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.