“Java vérifie si int” Réponses codées

test java si une chaîne est un 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
	}
  	
}
Drachir000

Comment vérifier si le numéro est entier en java

if(x == (int)x){
 println("x is an integer");
}
Expensive Echidna

Java vérifie si int

//"% (modulo)" calulates the remainder when the value on the left is divided by the value on the right

float number = 20;

if(number%1 == 0){
	println("It is an integer");
} else {
	println("It is not an integer");
}
earthstorm16

Réponses similaires à “Java vérifie si int”

Questions similaires à “Java vérifie si int”

Plus de réponses similaires à “Java vérifie si int” dans Java

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code