每次输入内容时,此代码都会继续循环.怎么解决?
public void inputPlayer()
{
Scanner input = new Scanner(System.in);
while(name.length() < 1)
{
System.out.println("Name: ");
this.setName(input.nextLine());
//name = input.nextLine();
if(name.length() < 1)
System.err.println("Must have one or more characters");
}
}
Run Code Online (Sandbox Code Playgroud)
Heres是整个事情的截图: