What is Character.isDigit() in Java?

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'));
}
}
New on Educative
Learn any Language for FREE all September 🎉
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources