Avatar of SunnyX
SunnyX

asked on 

Core java. Create the class with method that transform a collection of customer objects to string object collection.

Let there is pretty straightforward class

public class Employees {
    String lastName;

    Employees(String str) {
        this.lastName = str;

    }

    public String getLastName() {
        return lastName;
    }
}

Open in new window


public class EmployeesTest {

    public static void main(String[] args) { 
        new Employees("Smith");
        new Employees("Page");
        new Employees("Musk");
        new Employees("Dorsy");
        new Employees("Gates");
       
    }
}

Open in new window

I need to create some transform method that convert my employees collection into a String collection with last names of the employees. It is be best if the argument(s) of the method will be at topest level of collection hierarchy as much as possible ( Collection at best if it is possible  ) .
CollectionUtils.transform(stringList, employeesList);

Open in new window


Thx in advance.
JavaAlgorithms

Avatar of undefined
Last Comment
zzynx

8/22/2022 - Mon