Skip to content

Instantly share code, notes, and snippets.

@zaki-yama
Created April 28, 2015 09:59
Show Gist options
  • Select an option

  • Save zaki-yama/af4a4b68864af12d4854 to your computer and use it in GitHub Desktop.

Select an option

Save zaki-yama/af4a4b68864af12d4854 to your computer and use it in GitHub Desktop.
単語の先頭だけ大文字に変換するメソッド
public static void capitalize(String str){
List<String> words = str.split(' '); // 単語に分ける
List<String> capitalizedWords = new List<String>();
for (String word : words) {
capitalizedWords.add(word.capitalize());
}
return String.join(capitalizedWords, ' ');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment