isUpperCase() Method in Java
Table of Content:
Description
The Character.isUpperCase(char ch) java method determines if the specified character is an uppercase character. 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.
This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the isUpperCase(int) method.
This method determines whether the specified char value is uppercase.
Method Syntax
public static boolean isUpperCase(char ch)
Method Argument
Data Type | Parameter | Description |
---|---|---|
char | ch | the character to be tested. Primitive character type. |
Method Returns
The isUpperCase(char ch) method of Character class returns true if the character is uppercase; false otherwise.
Compatibility
Requires Java 1.0 and up
Example
Below is a simple java example on the usage of isUpperCase(char ch) method of Character class.
public class MethodisUpperCase { public static void main(String args[]) { System.out.println(Character.isUpperCase('s')); System.out.println(Character.isUpperCase('S')); System.out.println(Character.isUpperCase('\n')); System.out.println(Character.isUpperCase('\t')); } }
output
Below is the sample output when you run the above example.
false true false false Press any key to continue . . .
Java Character isUpperCase(char ch) Example
Below is a simple java example on the usage of isUpperCase(char ch) method of Character class.
import java.util.Scanner; /* * This example source code demonstrates the use of * isUpperCase(char ch) method of Character class. */ public class CharacterIsUpperCaseChar { public static void main(String[] args) { // Ask for user input System.out.print("Enter a character:"); // use scanner to get the user input Scanner s = new Scanner(System.in); // get a single character char value = s.nextLine().toCharArray()[0]; // close the scanner object s.close(); // check if the user input is upper case or not boolean checkBool = Character.isUpperCase(value); // print result if(checkBool){ System.out.println("User input \'"+value+"\' is Upper case"); } else{ System.out.println("User input \'"+value+"\' is not Upper case"); } } }
output
Below is the sample output when you run the above example.
Enter a character:s User input 's' is not Upper case Press any key to continue . . . Enter a character:S User input 'S' is Upper case Press any key to continue . . .