I know that the random() method is used with a fixed integer that I should determine. However my need is to use the same function with a parameter, I mean an integer that I haven't now but it will be determined during the runtime. here's my code:
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Random r1 = new Random();
num1 = r1.nextInt(z);
if (num1 < z) {
//do something
} else {
//do other thing
}
}
});
z is the parameter it determined during the runtime.
Aucun commentaire:
Enregistrer un commentaire