I'm trying to capitalize the first letter of each word in a List
. Currently, I'm getting a "Lambda Expression not expected here", and I'm told that I can't convert a String to a void, which I'm not trying to do. I'm trying to capitalize the first letter of each string in an arrayList; I haven't been able to determine a way to do so without selecting+capitalizing the first char (as char or as substring) and then adding the rest of the word.
public List<String> capitalizeAllWords(ArrayList<String> words) {
return words.stream().collect(Collectors.toList().forEach(word ->
word.substring(0,1).toUpperCase() + word.substring(1))
);
}