check if string contains number java code example
Example 1: check if string contains numbers
str.matches(".*\\d.*");
Example 2: check if char is number java
Character.isDigit(str.charAt(i));
Example 3: java check if string is number
try {
int n = Integer.parseInt(str);
} catch (NumberFormatException e) {
// str is not a number
}