我正在 Netbeans 上编写此代码,但在第 44 行遇到错误 Exception in thread "main"java.lang.RuntimeException: Uncompilable source code - incomplete types: int Can be Convert to boolean。
我在两个网站上编写了此代码,它运行没有问题,但在 NetBeans 上我收到此错误。
我正在尝试获取此输出
输入三个整数: 1 4 0 选择状态: 用户做出的第一选择 (1) 用户做出第二选择 (4) 选择数 = 2
和这个输出
输入三个整数: 7 5 7 选择状态: 用户做出的第一选择 (7) 用户做出第二选择 (5) 用户做出第三选择 (7) 选择数 = 3
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Teacher's Copy");
Scanner input = new Scanner(System.in);
System.out.println("Enter three integers: ");
int firstchoice = input.nextInt();
int secondchoice = input.nextInt();
int thirdchoice = input.nextInt();
if (firstchoice == 0)
System.out.println("State of choices: \n" +
"no choices made yet");
else if (secondchoice == 0)
System.out.println("State of choices: \n" +
"user made firstchoice ( " +firstchoice + ") \n" +
"number of choices = 1");
if (thirdchoice == 0)
System.out.println("State of choices: \n" +
"user made firstchoice (" + firstchoice + ")\n" +
"user made secondchoice (" + secondchoice + ")\n" +
"number of choices = 2");
System.out.println("State of choices: \n" +
"user made firstchoice (" + firstchoice + ")\n" +
"user made secondchoice (" + secondchoice + ")\n" +
"user made thirdchoice (" + thirdchoice + ")\n" +
"number of choices = 3");
}
}
先谢谢大家了!
最佳答案
您的代码绝对正确。也许,当您尝试复制代码时,Netbeans 正在搞乱您
关于java - 为什么我的代码可以在某些网站上运行,但不能在 NetBeans 中运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59993992/