Java - Character Class isUpperCase() Method

Character class isUpperCase() method: Here, we are going to learn about the isUpperCase() method of Character class with its syntax and example. By Preeti Jain Last updated : March 17, 2024

Character class isUpperCase() method

  • isUpperCase() method is available in java.lang package.
  • isUpperCase() method is used to check whether the given char value is uppercase or not.
  • isUpperCase() method does not throw an exception at the time of checking the given char value is uppercase or not.

Syntax

public boolean isUpperCase (Char value);

Parameters

  • Char value – represents the char value to be checked.

Return Value

The return type of this method is boolean, it returns a boolean value based on the following cases,

  • It returns true, if the given char value is uppercase.
  • It returns false, if the given char value is not in uppercase.

Example

// Java program to demonstrate the example 
// of boolean isUpperCase (Char value) method of Character class

public class IsUpperCaseOfCharacterClass {
    public static void main(String[] args) {
        // It returns true because the passing 
        // character is in UpperCase   
        boolean result1 = Character.isUpperCase('P');

        // It returns false because the passing 
        // character is not in UpperCase  
        boolean result2 = Character.isUpperCase('p');

        // Display values of result1 , result2
        System.out.println("Character.isUpperCase('P'): " + result1);
        System.out.println("Character.isUpperCase('p'): " + result2);
    }
}

Output

Character.isUpperCase('P'): true
Character.isUpperCase('p'): false

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.