Java – print all strings from the list by passing in a char variable
                                        
                    •
                    Java                                    
                I need to print all strings in the list by passing in a char variable
When I have something I like, for example, I pass char P
public static void printStrings(List<String> words,char p)
{
words.stream()
.filter(i -> i.startsWith(p)) 
.sorted()
.forEach(System.out::println);
}
How do I pass char variables because I keep getting error messages
error: incompatible types: char cannot be converted to String
So how to pass in a char variable without receiving an error?
Solution
String:: startswith can only accept string as a parameter
attempt
.filter(i -> i.startsWith(Character.toString(p)))
                            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
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        