Answers for "check if entered string is integer or not in java"

8

java test if a string is a int

public static boolean isInt(String str) {
	
  	try {
      	@SuppressWarnings("unused")
    	int x = Integer.parseInt(str);
      	return true; //String is an Integer
	} catch (NumberFormatException e) {
    	return false; //String is not an Integer
	}
  	
}
Posted by: Guest on May-28-2020
3

how to check if number is integer in java

if(x == (int)x){
 println("x is an integer");
}
Posted by: Guest on October-28-2020

Code answers related to "check if entered string is integer or not in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language