How to capitalize the String first letter of each word in Java
In this post we will give you information about How to capitalize the String first letter of each word in Java. Hear we will give you detail about How to capitalize the String first letter of each word in JavaAnd how to use it also give you demo for it if it is necessary.
This below example will show you, how to capitalize the first letter of a each word in a given stringJava.
public class Main{ public static String toTitleCase(String word){ return Character.toUpperCase(word.charAt(0)) + word.substring(1);}public static void main(String[] args){ String phrase = "you can see me first letter capital"; String[] splitPhrase = phrase.split(" "); String result = ""; for(String word: splitPhrase){ result += toTitleCase(word) + " "; } System.out.println(result.trim()); }}
Output:
You Can See Me First Letter Capital
Hope this code and post will helped you for implement How to capitalize the String first letter of each word in Java. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs