Hurry! Try our new Interactive Courses for FREE. 🥳   🚀

Java Character isUpperCase(char ch) Method

Java isUpperCase(char ch) method is a part of Character class. This method is used to check whether the specified character is an uppercase character or not.

This method does not support supplementary characters. A character is uppercase if its general category type, provided by Character.getType(ch), is UPPERCASE_LETTER. or it has contributory property Other_Uppercase as defined by the Unicode Standard.

Syntax:

public static boolean isUpperCase(char ch)

Parameters:

The parameter passed is the character to be checked whether it is an uppercase character.

Returns:

Returns the boolean value true if the specified character is an uppercase character else return false.

Example 1:

Here, the characters are checked whether they are uppercase characters or not.

public class StudyTonight
{  
	public static void main(String[] args)
	{  
		char ch1 = '0';  
		char ch2 = 'd';  
		char ch3 = 'D';  
		char ch4 = 'k';   
		char ch5 = 'P';  

		boolean b1 = Character.isUpperCase(ch1);  
		boolean b2 = Character.isUpperCase(ch2);  
		boolean b3 = Character.isUpperCase(ch3);  
		boolean b4 = Character.isUpperCase(ch4);  
		boolean b5 = Character.isUpperCase(ch5);  

		System.out.println(ch1 +" is uppercase character??:  "+b1);  
		System.out.println(ch2 +" is uppercase character??:  "+b2);  
		System.out.println(ch3 +" is uppercase character??:  "+b3);  
		System.out.println(ch4 +" is uppercase character?? : "+b4);  
		System.out.println(ch5 +" is uppercase character??:  "+b5);  
	}  
} 


0 is uppercase character??: false
d is uppercase character??: false
D is uppercase character??: true
k is uppercase character?? : false
P is uppercase character??: true

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);  
			boolean b = Character.isUpperCase(ch);
			System.out.println(ch + " is a uppercase character??: "+b);
		}
		catch(Exception e)
		{
			System.out.println("Invalid Input!!");
		}
	}  
}


Enter the character: e
e is a uppercase character??: false
*******************************************
Enter the character: U
U is a uppercase character??: true

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.