toMap method in Collection
Marcos Antonio
marcos_antonio_ps at hotmail.com
Sat Nov 19 08:48:44 PST 2011
Hello, everybody! Now that Java 8 will have lambda and extension methods, don't you think that a 'toMap' methodwould be another useful method to be added to the Collection interface? For example: Set<Employee> employees = ...Map<Integer, Employee> emp = employees.toMap(Employee::getID); Now 'emp' is a map with Employee objects as values and the employees' ids as keys. So themap values are always the elements of the collection, but the user is free to choose what the mapkey will be. Thank you. Marcos
More information about the lambda-dev
mailing list