请改为下面这样:Scanner input = new Scanner (System.in); System.out.println("请输入账号:"); String name= input.next(); while (name.length()<3){ System.out.println("输入错误请重新输入"); name = input.next(); }