Random
Know how to create a Random object and use it to create a random integer within a specified range.
If you want to make anything random, you need to first make a Random object like this:
Random objects can also generate a random double (between 0.0 and 1.0) or random a boolean (true or false) as follows:
Random generator = new Random();If you then need a random integer, you can ask the Random object to make you one like this:
int x = generator.nextInt(100);The number in parentheses limits the range of the number you might get. In this case, x will be a number between 0 and 99 (inclusive).
Random objects can also generate a random double (between 0.0 and 1.0) or random a boolean (true or false) as follows:
double decimal = generator.nextDouble(); boolean simonSays = generator.nextBoolean();