Java program to capitalize first letter of each word in a string
import java.lang.*;
public class HelloWorld{
public static void main(String []args){
String s = "biplav kumar mazumdar"; //aadd space
s = " "+s;
String f = "";
for(int i = 0;i<s.length();i++){
char ch = s.charAt(i);
if(ch==' '){
f = f+ch;
i++;
ch = s.charAt(i);
f = f+Character.toUpperCase(ch);
}else{
f = f+ch;
}
f = f.trim();
}
System.out.print(f);
}
}
Comments
Post a Comment