Welcome to the World of Online Learning:
Hello Friends “This blog helps you to learn Java programming concepts. You can learn Java language at your own speed and time. One can learn concepts of Java language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Write a Java Program to Capitalize the first character of each word in a String
PROGRAM: Java Program to Capitalize the first character of each word in a String
/*Java Program to Capitalize the first character of each word in a String*/
1: Java program to make the first letter of a String capital
class Main {
public static void main(String[] args) {
// create a string
String name = “programiz”;
// create two substrings from name
// first substring contains first letter of name
// second substring contains remaining letters
String firstLetter = name.substring(0, 1);
String remainingLetters = name.substring(1, name.length());
// change the first letter to uppercase
firstLetter = firstLetter.toUpperCase();
// join the two substrings
name = firstLetter + remainingLetters;
System.out.println(“Name: ” + name);
}
}
2: Convert every word of a String to uppercase
class Main {
public static void main(String[] args) {
// create a string
String message = “everyone loves java”;
// stores each characters to a char array
char[] charArray = message.toCharArray();
boolean foundSpace = true;
for(int i = 0; i < charArray.length; i++) {
// if the array element is a letter
if(Character.isLetter(charArray[i])) {
// check space is present before the letter
if(foundSpace) {
// change the letter into uppercase
charArray[i] = Character.toUpperCase(charArray[i]);
foundSpace = false;
}
}
else {
// if the new character is not character
foundSpace = true;
}
}
// convert the char array to the string
message = String.valueOf(charArray);
System.out.println(“Message: ” + message);
}
}