Java int一个方法

     int isNumeric(String str) throws ErrorException {
        for (int i = str.length(); --i >= 0;) {
            if (!Character.isDigit(str.charAt(i)))
                throw new ErrorException("不是正整数");
        }
        return Integer.parseInt(str);
    }

throw也可以被认为返回int值

猜你喜欢

转载自blog.csdn.net/lyj_88/article/details/83868813