isDigit in Java

isDigit is a static method of Character class. It is used to determine whether a character is a digit or not. If the character is digit then isDigit return true otherwise it return false.

Let us look at an example code :

public class IsDigitMethod {

	public static void main(String[] args) {
		
		boolean status1 = Character.isDigit('a');
		boolean status2 = Character.isDigit('8');
		
		System.out.println("Status of digit for a = "+status1);
		System.out.println("Status of digit for 8 = "+status2);
	}

}

Output

Status of digit for a = false
Status of digit for 8 = true

Leave a Comment