Java判断字符串是否实际上是整数

/**
 * @Description 判断字符串是否实际上是整数
 * @Author .Mark
 * @Date 2019年1月30日
 */
public static Boolean isInteger(String str) {
    // 1.限制入参
    if (str == null || "".equals(str)) {
        return false;
    }
    
    // 2.判断
    for (int i = 0; i < str.length(); i++) {
        if (!Character.isDigit(str.charAt(i))) {
            return false;
        }
    }
    
    return true;
}

猜你喜欢

转载自blog.csdn.net/weixin_34850743/article/details/86702229