1public static boolean isInt(String str) {
2
3 try {
4 @SuppressWarnings("unused")
5 int x = Integer.parseInt(str);
6 return true; //String is an Integer
7 } catch (NumberFormatException e) {
8 return false; //String is not an Integer
9 }
10
11}
1//"% (modulo)" calulates the remainder when the value on the left is divided by the value on the right
2
3float number = 20;
4
5if(number%1 == 0){
6 println("It is an integer");
7} else {
8 println("It is not an integer");
9}