import java.util.Random;
import java.util.Scanner;
public class Lottery
{
private int[] lotteryNumbers = new int[5];
private int counter;
private int[] userNumbers = new int[5];
private Scanner keyboard = new Scanner(System.in);
public Lottery()
{
for(counter = 0; counter < 5; counter++)
{
lotteryNumbers[counter] = nextInt(int 10);
}
}
后面还有更多代码,但没有错误,所以我不会包含它。 无论如何,“lotteryNumbers[counter] = nextInt(int 10);”这一行得到一个“.class expected”错误。
最佳答案
Java 已经知道方法参数的类型;调用该方法时无需指定它。
nextInt(int 10);
应该是:
nextInt(10);
当然,这是假设您实际上定义了方法 nextInt
。 (我在您的代码示例中没有看到它)
关于Java ".class expected",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10080862/