gpt4 book ai didi

Java ".class expected"

转载 作者:搜寻专家 更新时间:2023-11-01 01:23:03 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com