Java Character toLowerCase() Example

Java Character API comes with many methods to convert a character’s type to another type. toLowerCase(char ch) converts uppercase ch letter to lowercase. After conversion, you can check the character is really converted or not with isLowerCase() method. If the character is already a lowercase one, it is returned as it is by the method.

Following is the method signature as defined in java.lang.Character class.

  • public static char toLowerCase(char ch): Converts the character ch from uppercase to lowercase.

Following example illustrates. Purposefully, one lowercase letter ch2 is taken and converted to lowercase. See the code.

public class CharacterFunctionDemo
{
  public static void main(String args[])
  {
   char ch1 = 'A';
   char ch2 = 'a';     

   char ch3 = Character.toLowerCase(ch1);
   char ch4 = Character.toLowerCase(ch2);

   System.out.println(ch1 + " is converted to " + ch3);     
   System.out.println(ch2 + " is converted to " + ch4);   

   System.out.println("\nch3 is lowercase letter: " + Character.isLowerCase(ch3));
   System.out.println("ch4 is lowercase letter: " + Character.isLowerCase(ch4));
  }
}

Java Character toLowerCase() Example

Character.isLowerCase(char ch)

Checks the character is lowercase of not. If lowercase, the method returns true else false. See the usage of toUpperCase().

Leave a Comment

Your email address will not be published.