Java - Character Class isLetter() Method

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

Character class isLetter() method

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

Syntax

public boolean isLetter (Char c);

Parameters

  • Char c – 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 either letter or character.
  • It returns false, if the given char value is not either letter or character.

Example

// Java program to demonstrate the example 
// of boolean isLetter (Char c) method of Character class

public class IsLetterOfCharacterClass {
    public static void main(String[] args) {
        // It returns true because the passing 
        // character is a letter   
        boolean result1 = Character.isLetter('a');

        // It returns false because the passing 
        // character is not a letter   
        boolean result2 = Character.isLetter('7');

        // Display values of result1 , result2
        System.out.println("Character.isLetter('a'): " + result1);
        System.out.println("Character.isLetter('7'): " + result2);
    }
}

Output

Character.isLetter('a'): true
Character.isLetter('7'): false

Comments and Discussions!

Load comments ↻





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