java.util.Random
A class that produces pseudorandom values of several primitive types.
What is java.util.Random in Java?
java.util.Random — A class that produces pseudorandom values of several primitive types.
import java.util.Random;
class Dice {
Random random = new Random();
int roll() {
return random.nextInt(6) + 1;
}
}
Level: Apprentice · More Java terms at this level
Updated