Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java ".class expected"

Tags:

java

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);
        }
    }

There is more code after, but there are no errors there, so I'm not gonna include it. Anyway, the line that says "lotteryNumbers[counter] = nextInt(int 10);" get a ".class expected" error.

like image 585
Chris Avatar asked Dec 07 '22 15:12

Chris


1 Answers

Java already knows the type of the method parameter; you don't need to specify it when you call the method.

nextInt(int 10);

Should be:

nextInt(10);

This is assuming, of course, that you actually have a method nextInt defined. (I don't see it in your code sample)

like image 155
Kirk Woll Avatar answered Dec 09 '22 05:12

Kirk Woll