我设计了一个循环来验证用户对问题的输入,在我添加它之前它工作正常;
if (userInput.charAt(0) > NUMCOLS && userInput.charAt(0) < 0);
{
System.out.println("Error, " + userInput + " is an invalid move.");
continue;
}
在此之前
if (userInput.charAt(2) !='-')
{
System.out.println("Error, " + userInput + " is an invalid move.");
continue;
}
现在,每当我尝试编译时,都会收到一条错误,指出这是一个无法访问的语句,是什么原因导致的?
最佳答案
有一个虚假的“;”在添加的代码的第一行中,使第一个 continue;
始终执行!
关于java - 无法到达的声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2384603/