I'm trying to call this method outside of main()
in order to assign a variable by chance. The compiler gives "invalid method declaration". How can I get this if
statement to run in the class? Thank you for the help.
I have tried to write the if
statement directly into the class but then the reference to num
in the if
statement isn't recognized.
(if(20 <= num)
)
pseudocode:
public class Class{
private static int num = numGen(); //random num
method(num);
private static void method(int chance){
if(20 <= chance){
//stuff happens here
}
}
}
Aucun commentaire:
Enregistrer un commentaire