当我在 NETBEANS IDE 8.0
中播放它时,它一直说没有主类,即使我已经添加了主类?
求助看不懂。
PS. 如果我删除 magic() 中的 static,它会阻塞 main 中的 magic()。
package fibotail;
import java.util.Scanner;
public class Fibotail {
public static int fibo(int control, int currentValue, int previousValue) {
if (control < 2) {
return currentValue;
}
return fibo(control - 1, currentValue + previousValue, currentValue);
}
public static void magic() {
String cCharacter;
do {
System.out.println("Input here: ");
int something = new Scanner(System.in).nextInt();
for (int i = 1; fibo(i, 0, 1) <= something; i++) {
System.out.println(fibo(i, 0, 1));
}
do {
System.out.println("Do you want to try again? ");
cCharacter = new Scanner(System.in).next();
} while (!(cCharacter.equals("y") || cCharacter.equals("Y") || cCharacter.equals("N") || cCharacter.equals("n")));
} while (cCharacter.equals('y') || cCharacter.equals('Y'));
}
public static int main(String args[]) {
magic();
return 0;
}
}
最佳答案
返回类型应该是void
,而不是int
:
public static void main(String args[]) { ... }
JVM 查找方法的确切签名。
关于java - 没有找到主要类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25073585/