is all character in string Numeric - Android java.lang

Android examples for java.lang:String Convert

Description

is all character in string Numeric

Demo Code


public class Main{

    public static boolean isNumeric(String str) {
        if (str == null)
            return false;

        for (char c : str.toCharArray()) {
            if (!Character.isDigit(c))
                return false;
        }/* ww w. j  a  va 2 s .c  om*/
        return true;
    }

}

Related Tutorials