Convert an object to another type using map() method with Lambda in Java?

In Java 8, we have the ability to convert an object to another type using a map() method of Stream object with a lambda expression. The map() method is an intermediate operation in a stream object, so we need a terminal method to complete the stream.


<R>Stream <R> map(Function<? super T,? extends R> mapper)


import java.util.*;

public class EmployeeInformationTest {
   public static void main(String args[]) {
      List<Employee> employees = Arrays.asList(
         new Employee("Jai"),
         new Employee("Adithya"),
         new Employee("Raja"));
      List<String> names =
         .map(s -> s.getEmployeeName())              // Lambda Expression

// Employee class
class Employee {
   private String empName;
   private String empDesignation;
   public Employee(String empName) {
      this.empName = empName;
   public String getEmployeeName() {
      return empName;
   public void setEmployeeName(String empName) {
      this.empName = empName;
   public String getEmployeeDesignation() {
      return empDesignation;
   public void setEmployeeDesignation(String empDesignation) {
      this.empDesignation = empDesignation;


[Jai, Adithya, Raja]