Source Code : Capitalizing each word in a sentence with recursive function
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Capitalizing each word in a sentence with recursive function
public class Main {
public static void main(String[] args) {
String sentence = "this is a test";
System.out.println(capSentence(sentence, true));
}
public static String capSentence(String string, boolean capitalize) {
if (string.length() == 0) {
return "";
}
String c = string.substring(0, 1);
if (capitalize) {
return c.toUpperCase() + capSentence(string.substring(1), c.equals(" "));
} else {
return c.toLowerCase() + capSentence(string.substring(1), c.equals(" "));
}
}
}
Thank with us