check if character is number java code example
Example 1: check if char is number java
Character.isDigit(str.charAt(i));
Example 2: how to check if a char is a letter java
Character.isDigit(string.charAt(index)) //(JavaDoc) will return true if it's a digit
Character.isLetter(string.charAt(index)) //(JavaDoc) will return true if it's a letter
Example 3: java check if string is number
try {
int n = Integer.parseInt(str);
} catch (NumberFormatException e) {
// str is not a number
}