如何使用随机类创建参数?我这样做,但它发出一条错误消息。
import java.util.Random;
public class DiceSimulation {
public static void main(String[] args)
{
final int NUMBER = 10000;
Random generator = new Random();
int die1Value; int die2Value; int count = 0; int snakeEyes = 0;
int twos = 0; int threes = 0; int fours = 0; int fives = 0;
int sixes = 0;
while (count < NUMBER) {
die1Value = generator.nextInt(1, 6);
die2Value = generator.nextInt(1, 6);
if (die1Value == die2Value) {
if(die1Value == 1) { snakeEyes++; }
else if (die1Value == 2) { twos++; }
else if (die1Value == 3) { threes++; }
else if (die1Value == 4) { fours++; }
else if (die1Value == 5) { fives++; }
else if (die1Value == 6) { sixes++; }
}
count++;
}