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
Thx in advance.
public class Employees {
String lastName;
Employees(String str) {
this.lastName = str;
}
public String getLastName() {
return lastName;
}
}
public class EmployeesTest {
public static void main(String[] args) {
new Employees("Smith");
new Employees("Page");
new Employees("Musk");
new Employees("Dorsy");
new Employees("Gates");
}
}
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);
Thx in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thx for the help
why are you passing in the string collection as the first argument: transform(Collection<Strin g> strCollection, Collection myCollection) {
You don't need to.
You don't need to.
>> thx for the help
You're welcome.
Thanx 4 axxepting
You're welcome.
Thanx 4 axxepting
ASKER
Open in new window
Like this ?
is there a way to do it smarter ?