Home » Java programming language

Java Character class isLetter() method with example

Character class isLetter() method: Here, we are going to learn about the isLetter() method of Character class with its syntax and example.
Submitted by Preeti Jain, on October 26, 2019

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);

Parameter(s):

  • 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

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.