JavaFX – from list to map using java 8
                                        
                    •
                    Java                                    
                Is it possible to generate hashmaps using streams and collectors?
myList.stream() .map(Label::new) .collect(Collectors.toMap(Function.identity(),PasswordField::new))
But it obviously didn't work. I tried other solutions, but failed Do you have any suggestions?
Solution
The passwordfield class has only one default constructor, which means that passwordfield:: new will not work because it is equivalent to (label L) – > New passwordfield (L) Instead, the value mapper should be (label L) – > New passwordfield() or a simple L – > New passwordfield();
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        