jeudi 26 mai 2016

The method nextInt(int) is undefined for the type Random

Can someone help me with this error. I m trying to generate some random numbers but this error displays:The method nextInt(int) is undefined for the type Random. Even though i have imported java.util.Random it says:The import java.util.Random conflicts with a type defined in the same file. This is my code:

import java.util.Random;
public class Random {

        public static void main(String[] args) {
                
                Random object=new Random();
                int number;
                number=1+object.nextInt(6);
        
        }

}



Aucun commentaire:

Enregistrer un commentaire