gpt4 book ai didi

java - 无法到达的声明

转载 作者:行者123 更新时间:2023-12-01 06:29:07 28 4
gpt4 key购买 nike

我设计了一个循环来验证用户对问题的输入,在我添加它之前它工作正常;

        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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com