macos Java NoSuchMethodError:main
我正在通过终端在OSX上学习Java。当我编译下面的代码时,我没有得到任何错误,但是当我试图运行它时,我得到了错误
Exception in thread "main" java.lang.NoSuchMethodError: main
我的代码:
public class Problem5{
public void main(String[] args) {
int n = 1;
while(!checkMod(n)){
n++;
}
}
public boolean checkMod(int in)
{
int count = 0;
for(int i=1; i<20; i++)
{
if(in%i == 0)
{
count = count + 1;
}
}
if(count ==19)
{
return true;
}
else{
return false;
}
}
}
我从main方法中删除了“static”,因为我调用了checkMod方法
如何正确地编写代码
谢谢
共 (0) 个答案