The method toLowerCase( ) converts all the characters in a string from uppercase to lowercase. The toUpperCase( ) method converts all the characters in a string from lowercase to uppercase. Non alphabetical characters, such as digits, are unaffected.

Here is an example that uses toLowerCase( ) and toUpperCase( ):

// Demonstrate toUpperCase() and toLowerCase().
class ChangeCase {
public static void main(String args[])
{
String s = "This is a test.";
System.out.println("Original: " + s);
String upper = s.toUpperCase();
String lower = s.toLowerCase();
System.out.println("Uppercase: " + upper);
System.out.println("Lowercase: " + lower);
}
}

Output

Original: This is a test.
Uppercase: THIS IS A TEST.
Lowercase: this is a test.