Trusted answers to developer questions

What is Character.isDigit() in Java?

Free System Design Interview Course

Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2024 with this popular free course.

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

Figure 1 shows a visual representation of the isDigit() function.

Figure 1: Visual representation of isDigit() function

Syntax

boolean isDigit(char character)

Parameter

The isDigit() function takes the character as a parameter.

Return value

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

Code

class JAVA {
public static void main( String args[] ) {
//simple character
System.out.println("Character.isDigit('E'):");
System.out.println(Character.isDigit('E'));
//digit character
System.out.println("Character.isDigit('5'):");
System.out.println(Character.isDigit('5'));
}
}

RELATED TAGS

java
digit
Did you find this helpful?