Is possibile to generate an HashMap using stream and collector? I've tried with something like:
myList.stream()
.map(Label::new)
.collect(Collectors.toMap(Function.identity(), PasswordField::new))
but it obviusly doesn't work, I've tried other solution, but without success. Have you some advidce?
The PasswordField class only has a default constructor which means PasswordField::new will not work as it's equivalent to (Label l) -> new PasswordField(l). instead the value mapper should be (Label l) -> new PasswordField() or simply l -> new PasswordField();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With