mercredi 19 avril 2017

Setting a public int to a random number

I want to make a public int set to a random. But, I have a problem.

public static int response = rand.nextInt(6) + 1;

    public static void main(String []args){

        Random rand = new Random();

This code doesn't work. I get that since the random is inside of the main method the public int can't retrieve the rand. Is there any way I can have a public int set to a random number?




Aucun commentaire:

Enregistrer un commentaire