Using Random Class
You must include random class
import java.util.Random;
Random r = new Random();
will create an instance of the Random class
n = r.nextInt(6); // return int between 0 and 5
n = r.nextInt(11)+10; // returns int between 10 and 20
double d = r.nextDouble(); // returns double between 0 and 1.0