0

当我运行下面的代码时,我得到了找不到或加载main类的错误。我已删除该包并再次创建它。但是错误仍然存​​在。我做了一些方法来修复它,例如右键单击包name -> properties -> run选项来更改main方法,但是什么也没有。但是,如果我创建另一个包名称并在其中编写此代码,则程序可以工作。

package craps;

public class Craps {


public static void main(String[] args) {
    int number = 10;
    System.out.println(number);
}   

}

4

1 回答 1

0

您的代码没有任何错误我不知道 Netbeans 中发生了什么。我多年来一直在使用它并且生活在这种错误中。也许当 netbeans 内存不足并且您正在编辑此文件的特定时刻时,您会得到这个。

My workaround for this kind of errors are
1.Do some dummy editing in that file like commenting some empty line // and save All and recompile it
2.Close and open this project (Sometimes work)
于 2014-03-29T09:37:57.067 回答