public class FirstWordUpperCase {
public static void main(String[] args) {
System.out.println(changeString("how are you man"));
}
private static String changeString(String str) {
StringBuffer sb = new StringBuffer();
String[] arr = str.split("\\s");
for (int i = 0; i < arr.length; i++) {
sb.append(Character.toUpperCase(arr[i].charAt(0))).
append(arr[i].substring(1)).append(" ");
}
return sb.toString();
}
}
Friday, 7 December 2018
Java program to capitalize first letter of each word in string
About Unknown
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment