This is the small java code that capitalized the each word of a string. The Java built-in function is used in the code for this purpose.
Source Code
package newpackage;
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;
}
}
No comments:
Post a Comment