Signup/Sign In

Java Character toLowerCase(char ch) Method

Java toLowerCase(char ch) method is a part of Character class. This method converts the given character argument to the lowercase using case mapping information which is provided by the Unicode Data file.

Syntax:

public static char toLowerCase(char ch) 

Parameters:

The parameter passed is the 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 characters are converted into its equivalent lowercase characters.

public class StudyTonight
{  
	public static void main(String[] args)
	{  
		char ch1 = 'F';  
		char ch2 = 'n';
		char ch3 = '1';

		char ch11 = Character.toLowerCase(ch1);  
		char ch22 = Character.toLowerCase(ch2);
		char ch33 = Character.toLowerCase(ch3);

        System.out.println("The lowercase character is : "+ch11);  
		System.out.println("The lowercase character is : "+ch22); 
		System.out.println("The lowercase character is : "+ch33); 
	}  
}


The lowercase character is : f
The lowercase character is : n
The lowercase character is : 1

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 character: ");  
			Scanner sc = new Scanner(System.in);         
			char ch = sc.next().charAt(0);  
			char cc = Character.toLowerCase(ch);
			System.out.println("The lowercase character is : "+cc);
		}
		catch(Exception e)
		{
			System.out.println("Invalid Input!!");
		}
	}  
}


Enter the character: L
The lowercase character is : l
*************************************
Enter the character: q
The lowercase character is : q

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.



About the author:
A Computer Science and Engineering Graduate(2016-2020) from JSSATE Noida. JAVA is Love. Sincerely Followed Sachin Tendulkar as a child, M S Dhoni as a teenager, and Virat Kohli as an adult.