Use Character.isDigit to check the if a char is a digit in Java
Description
The following code shows how to use Character.isDigit to check the if a char is a digit.
Example
/*w w w. ja va 2s .c o m*/
public class Main {
public static void main(String[] args) {
System.out.println("Is the Latin symbol 6 a digit? " + Character.isDigit('6'));
System.out.println("Is the Tamil symbol corresponding to "
+ "Unicode value '\\u0beb' a digit? " + Character.isDigit('\u0beb'));
System.out.println("Is the Greek symbol Omega a digit? " + Character.isDigit('\u03a9'));
System.out.println("Is the Latin symbol A a digit? " + Character.isDigit('A'));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »