Java 我无法在Eclipse中运行此程序
我无法在Eclipse中运行此程序。Eclipse没有说有什么问题,我就是打不开。每次我尝试时,它都会在我的默认包中打开另一个程序Java 我无法在Eclipse中运行此程序,java,Java,我无法在Eclipse中运行此程序。Eclipse没有说有什么问题,我就是打不开。每次我尝试时,它都会在我的默认包中打开另一个程序 import acm.util.*; /** * This class decides the face of a coin. * 1 and 2 represent correspondingly Heads and Tails. * Clients can get the "face" of the coin by calling getState()
import acm.util.*;
/**
* This class decides the face of a coin.
* 1 and 2 represent correspondingly Heads and Tails.
* Clients can get the "face" of the coin by calling getState() method.
*/
public class CoinFace {
public CoinFace() {
state = rgen.nextInt(1, 2);
}
private int state;
public int getState() {
return state;
}
private RandomGenerator rgen = new RandomGenerator();
}
public class ConsecutiveHeads extends CoinFace{
public void run () {
while (true) {
int totalFlip = 0;
int consecutiveHeads = 0;
CoinFace a = new CoinFace();
if (a.getState() == 1) {
System.out.print("Heads");
totalFlip++;
consecutiveHeads++;
} else if (consecutiveHeads == 3) {
System.out.print("It took " + totalFlip + " to get 3 consecutive heads." );
break;
} else {
System.out.print("Tails");
consecutiveHeads = 0;
}
}
}
}
您忘记声明主方法:
public static void main(String args[]) {
new ConsecutiveHeads().run();
}
那么当你尝试时会发生什么呢?什么是铸币面?你的主要方法是什么?你没有给我们足够的信息。请阅读我在这里看不到主要方法我真的希望你在那里有主要方法@ᴍ阿伦ᴍ阿隆,他也希望:D-1指责日食。