Display first fetter of a word with Capital letter in a given Sentence or String
The below code will display every first letter of a word in the sentence will display as a capital letter or in Camel Case using java program.
Output:
package com.javabynataraj.strings;
public class StringSpace {
public static void main(String[] args) {
String input = "HE IS A GOOD BOY";
StringBuilder sb = new StringBuilder();
for( String oneString : input.toLowerCase().split(" ") )
{
sb.append( oneString.substring(0,1).toUpperCase() );
sb.append( oneString.substring(1)+" " );
}
System.out.println("Output--> "+sb);
}
}
Output:
Output--> He Is A Good Boy
