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 to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources