“Como verificar se a análise no número inteiro é possível em java” Respostas de código

Java verifique se capaz de analisar int

public static boolean isParsable(String input) {
    try {
        Integer.parseInt(input);
        return true;
    } catch (final NumberFormatException e) {
        return false;
    }
}
Zwazel

Como verificar se a análise no número inteiro é possível em java

// if parse is possible then it will do it otherwise compiler 
// will throw exceptions and it is a bad practice to catch all exceptions
// in this case only NumberFormatException happens
public boolean isInteger(String string) {
    try {
        Integer.valueOf(string);
        // Integer.parse(string) /// it can also be used
        return true;
    } catch (NumberFormatException e) {
        return false;
    }
}
rng70

Respostas semelhantes a “Como verificar se a análise no número inteiro é possível em java”

Perguntas semelhantes a “Como verificar se a análise no número inteiro é possível em java”

Procure respostas de código populares por idioma

Procurar outros idiomas de código