java.lang.Character isDigit(char ch)


The Character.isDigit(char ch) java method determines if the specified character is a digit.

A character is a digit if its general category type, provided by Character.getType(ch), is DECIMAL_DIGIT_NUMBER.

Some Unicode character ranges that contain digits:

  • ‘u0030’ through ‘u0039’, ISO-LATIN-1 digits (‘0’ through ‘9’)
  • ‘u0660’ through ‘u0669’, Arabic-Indic digits
  • ‘u06F0’ through ‘u06F9’, Extended Arabic-Indic digits
  • ‘u0966’ through ‘u096F’, Devanagari digits
  • ‘uFF10’ through ‘uFF19’, Fullwidth digits

Many other character ranges contain digits as well.

Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the isDigit(int) method.

The isDigit(char ch) method of Character class is static thus it should be accessed statically which means the we would be calling this method in this format:

Character.isDigit(char ch)

Non static method is usually called by just declaring method_name(argument) however in this case since the method is static, it should be called by appending the class name as suffix. We will be encountering a compilation problem if we call the java isDigit() method non statically.

Method Syntax

public static boolean isDigit(char ch)

Method Argument

Data Type Parameter Description
char ch the character to be tested.

Method Returns

The isDigit(char ch) method of Character class returns true if the character is a digit; false otherwise.


Requires Java 1.0 and up

Java Character isDigit(char ch) Example

Below is a simple java example on the usage of isDigit(char ch) method of Character class.


import java.util.Scanner;

 * This example source code demonstrates the use of 
 * isDigit(char ch) method of Character class.

public class CharacterIsDigitCharExample {

	public static void main(String[] args) {

		// Ask for user input
		System.out.print("Enter a character:");
		// use scanner to get the user input
		Scanner s = new Scanner(;
		// get a single character
		char value = s.nextLine().toCharArray()[0];
		// close the scanner object
		// check if the user input is digit or not
		boolean checkBool = Character.isDigit(value);
		// print result
			System.out.print("User input '"+value+"' is a digit");
			System.out.print("User input '"+value+"' is not a digit");


Sample Output

Below is the sample output when you run the above example.

java Character isDigit(char ch) example output