vendredi 29 mai 2020

Can I use a randomly generated number as a parameter to a method in Java?

So I'm very new to Java so this question might have a pretty simple answer. I'm trying to create a Magic8 ball program and I want the fortune to depend on the randomly generated number, but it's treated as a method and I'm not sure that a method can have another method as a parameter.

public int generator(){
    int num = rnd.nextInt(2) + 1;
return num;
}

That's my method to generate the random number, is there a way to use the product of this in another method?




Aucun commentaire:

Enregistrer un commentaire