In this post, I will be sharing how to check if a Character is Uppercase or not in Java. We can easily achieve our goal of checking if a Character is Uppercase or not by using the Character.isUpperCase() method.
Read Also: char to Character in Java
Related Articles
Check if a Character is Uppercase or not in Java
1. Using Character class isUpperCase() method
According to Oracle docs, the Character.isUpperCase() method can be used to determine if the specified character is an uppercase character.
The following are examples of uppercase characters:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
'\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
'\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
'\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
'\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
Note: Character.isUpperCase() method cannot handle supplementary characters.
Java Program
public class CheckCharacterUppercase { public static void main(String args[]) { char ch = 'A'; if(Character.isUpperCase(ch)) { System.out.println("Given character is Uppercase"); } else { System.out.println("Given character is NOT Uppercase"); } } }
Output:
Given character is Uppercase
That's all for today. Please mention in the comments if you know any other way of checking if a character is uppercase or not in Java.