Let's say I have this code:
Map<String, String> map;
// later on
map.entrySet().stream().map(MyObject::new).collect(Collectors.toList());
And I have a MyObject
Constructor
which takes two arguments of type String
.
I want to be able to do this but I cannot.
I know I can do e -> new MyObject(e.getKey(), e.getValue())
but prefer MyObject::new
.
Similar code works for Set<String>
and List<String>
with one argument constructor of MyObject
class.