这是我的代码
import java.util.Scanner;
public class Range {
public static void main(String[] args)
{
System.out.println("Greetings.");
int min,max;
System.out.println("Enter a minimum and maximum value.");
Scanner keyboard = new Scanner(System.in);
min = keyboard.nextInt();
max = keyboard.nextInt();
System.out.println("The number of values in the range from " + min + "to " + max + " is");
for (int i = min; i <= max; i++){
System.out.println(i);
}
}
}
异常(exception):
run:
Error: Could not find or load main class project.Project
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)
有人可以告诉我我做错了什么吗?
最佳答案
这不是编译器错误 - 这是当您尝试运行代码时出现的错误。
答案很简单 - 您正在尝试运行 project.Project
,但您的类实际上只是 Range
(在默认包中,从外观来看它)。
关于java - 无法在 NetBeans 中找到 main,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17377799/