Java.lang.Character.toLowerCase() Method

Advertisements


Description

The java.lang.Character.toLowerCase(char ch) converts the character argument to lowercase using case mapping information from the UnicodeData file.

Note that Character.isLowerCase(Character.toLowerCase(ch)) does not always return true for some ranges of characters, particularly those that are symbols or ideographs.

Declaration

Following is the declaration for java.lang.Character.toLowerCase() method

public static char toLowerCase(char ch)

Parameters

  • ch - the character to be converted

Return Value

This method returns the lowercase equivalent of the character, if any; otherwise, the character itself.

Exception

  • NA

Example

The following example shows the usage of lang.Character.toLowerCase() method.

package com.tutorialspoint;

import java.lang.*;

public class CharacterDemo {

   public static void main(String[] args) {

      // create 4 char primitives
      char ch1, ch2, ch3, ch4;

      // assign values to ch1, ch2
      ch1 = 'P';
      ch2 = 's';

      // assign lowercase of ch1, ch2 to ch3, ch4
      ch3 = Character.toLowerCase(ch1);
      ch4 = Character.toLowerCase(ch2);

      String str1 = "Lowercase of " + ch1 + " is " + ch3;
      String str2 = "Lowercase of " + ch2 + " is " + ch4;

      // print ch3, ch4 values
      System.out.println( str1 );
      System.out.println( str2 );
   }
}

Let us compile and run the above program, this will produce the following result:

Lowercase of P is p
Lowercase of s is s



Advertisements
Advertisements