In this tutorial, you are going to learn to write a java program to check whether a given character is in lowercase or uppercase.
For Example:
Suppose Given character input = a
then the output should be “Given character is in lowercase”
And If Given character input = A
then the output should be “Given character is in uppercase”
Java Program to check given character is in Uppercase or lowercase
import java.util.*;
public class Main
{
public static void main (String[]args)
{
System.out.println("UpperCase and LowerCase program in Java");
Scanner sc = new Scanner (System.in);
System.out.println ("Please enter a character");
char ch = sc.next().charAt (0);
if (Character.isUpperCase(ch))
{
System.out.println("Given Character is in UpperCase.");
}
else
System.out.println("Given Character is in LowerCase.");
}
}
Output 1:
UpperCase and LowerCase program in Java
Please enter a character
E
Given Character is in UpperCase.
Output 2:
UpperCase and LowerCase program in Java
Please enter a character
e
Given Character is in LowerCase.