Uncapitalize a string
In this chapter you will learn:
Uncapitalize a string
public class Main {
public static void main(String[] argv) {
System.out.println(uncaps("This is a test from java2s.com"));
}//from j av a 2 s. co m
public static String uncaps(String string) {
if (string.length() == 0) {
return string;
}
char ch = string.charAt(0);
if (Character.isUpperCase(ch)) {
ch = Character.toLowerCase(ch);
return ch + string.substring(1);
}
return string;
}
}
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » String