Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

java
characters
communitycreator

What is Character.isLetterOrDigit() in Java?

abhilash

Overview

The isLetterOrDigit() method is a static method in the Character class in Java, which is used to determine if the specified character is a letter or digit.

A character is determined a letter or a digit when either of the Character.isLetter() or Character.isDigit() methods return true.

Syntax

public static boolean isLetterOrDigit(char ch)

Parameters

char ch - The character to be checked for letter or digit.

Return value

The isLetterOrDigit() function returns true if the character sent as a parameter is a letter or a digit; otherwise, it returns false.

Example

In the code below, we test the function against letters, digits and special characters.

public class Main{

    public static void main(String[] args){
        System.out.println(Character.isLetterOrDigit('a'));
        System.out.println(Character.isLetterOrDigit('1'));
        System.out.println(Character.isLetterOrDigit('9'));
        System.out.println(Character.isLetterOrDigit('Z'));
        System.out.println(Character.isLetterOrDigit('.'));
        System.out.println(Character.isLetterOrDigit('!'));
    }
}

RELATED TAGS

java
characters
communitycreator
RELATED COURSES

View all Courses

Keep Exploring