java check if int is number code example
Example 1: java check if string is number
try {
int n = Integer.parseInt(str);
} catch (NumberFormatException e) {
// str is not a number
}
Example 2: how to check if number is integer in java
if(x == (int)x){
println("x is an integer");
}