java报错Cannot parse null string

问题遇到的现象和发生背景
 System.out.println("你所需的密码长度:");
        String str = Keyboard.readInput();
        int password= Integer.parseInt(str);
        if(password<8 || password>24){
            System.out.println(”输入错误重新输入");
            continue;
        } else {
            return password;
        }
运行结果及报错内容

IDE说continue不在loop里面
IDE 告诉我

Exception in thread "main" java.lang.NumberFormatException: Cannot parse null string

我想要达到的结果

为什么不可以转换string呢?我的string是用户输入的数字,是不可以用Integer.parseInt么?
还有我的continue不可以在这里用是为什么呀?
谢谢大家的帮助!

(1)continue 是用在循环语句中的,比如 for,while
(2)str 数据是 空字符串,Integer.parseInt 不能转换空字符串。检查一下str,可以打印一下看看。

什么都不输入会当成空字符串的 肯定报错啊 可以用 lang3里的 NumberUtils.toInt() 如果输入空 返回0