java is number

54

java is number -

String someString = "123123";
boolean isNumeric = someString.chars().allMatch( Character::isDigit );

java how to check string is number -

public static boolean isNumeric(String strNum) {
    if (strNum == null) {
        return false;
    }
    try {
        double d = Double.parseDouble(strNum);
    } catch (NumberFormatException nfe) {
        return false;
    }
    return true;
}

Comments

Submit
0 Comments