LAST UPDATED: NOVEMBER 24, 2020
Java Character toLowerCase(int codePoint) Method
Java toLowerCase(int codePoint)
method is a part of Character
class. This method converts the specified Unicode code point character argument to the lowercase using case mapping information which is provided by the Unicode Data file.
Syntax:
public static char toLowerCase(int codePoint)
Parameters:
The parameter passed is the Unicode code point character value to be converted.
Returns:
Returns the lowercase equivalent of the specified character, if any; otherwise, the character itself.
Example 1:
Here, the specified code points are converted into its equivalent lowercase characters.
public class StudyTonight
{
public static void main(String[] args)
{
int cp1 = 78;
int cp2 = 102;
int cp3 = 66;
int cp4 = 48;
int cp5 = 1232;
char ch1 = Character.toLowerCase((char)cp1);
char ch2 = Character.toLowerCase((char)cp2);
char ch3 = Character.toLowerCase((char)cp3);
char ch4 = Character.toLowerCase((char)cp4);
char ch5 = Character.toLowerCase((char)cp5);
System.out.println("The lowercase character is :"+ch1);
System.out.println("The lowercase character is :"+ch2);
System.out.println("The lowercase character is :"+ch3);
System.out.println("The lowercase character is :"+ch4);
System.out.println("The lowercase character is :"+ch5);
}
}
The lowercase character is :n
The lowercase character is :f
The lowercase character is :b
The lowercase character is :0
The lowercase character is :?
Example 2:
Here is a user-defined example where anyone using this code can put a value of his choice and get the equivalent output.
import java.util.Scanner;
public class StudyTonight
{
public static void main(String[] args)
{
try
{
System.out.print("Enter the Unicode codepoint: ");
Scanner sc = new Scanner(System.in);
int cp = sc.nextInt();
char cc = Character.toLowerCase((char)cp);
System.out.println("The lowercase character is : "+cc);
}
catch(Exception e)
{
System.out.println("Invalid Input!!");
}
}
}
Enter the Unicode codepoint: 77
The lowercase character is : m
***************************************
Enter the Unicode codepoint: 100
The lowercase character is : d
Live Example:
Here, you can test the live code example. You can execute the example for different values, even can edit and write your examples to test the Java code.