How to Capitalize First Letters of the Words in a Given String in Java

This is the simple and logic building java exercise for beginners. The program will Capitalize first letter of each word in a string, like string "All is well" will become "All Is Well".

Source Code 


package newpackage.more;
import java.util.Scanner;
import org.apache.commons.lang.WordUtils;

public class capitalizeFirst {
public static void main(String[] args) {
String userEntered, palindrome = "";
Scanner in = new Scanner(System.in);// java.util.Scanner
System.out.println("Enter some text to capitalize every first letter");
userEntered = in.nextLine();
System.out.println(WordUtils.capitalize(userEntered)); //org.apache.commons.lang.WordUtils;
}
}

Output of the Program

Capitalize First Letters of the Words in a Given String in Java



Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment