Skip to content

Instantly share code, notes, and snippets.

@Hylke1982
Created February 17, 2015 11:45
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Hylke1982/166a792313c5e2df9d31 to your computer and use it in GitHub Desktop.
Save Hylke1982/166a792313c5e2df9d31 to your computer and use it in GitHub Desktop.
Method to make first letter of a word capital
public String firstLetterCapitalWithSingleSpace(final String words) {
return Stream.of(words.trim().split("\\s"))
.filter(word -> word.length() > 0)
.map(word -> word.substring(0, 1).toUpperCase() + word.substring(1))
.collect(Collectors.joining(" "));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment