[an error occurred while processing this directive]
Except where otherwise noted, the contents of this document are Copyright 2013 Stuart Reges and Marty Stepp.
lab document created by Marty Stepp, Stuart Reges and Whitaker Brand
Randoms allow us to generate random* numbers. Just like with Graphics, where we made one pen that we used to draw on the DrawingPanel, we make one Random object and use that to generate Random values throughout our program.
Random randomName = new Random();
*Technically pseudorandom, because it's surprisingly hard to generate truly random values, but theyre random enough for this class!
||returns a random integer|
||returns a random real number in the range [0.0, 1.0).||
||returns a random integer in the range [0, max). In other words, the number can be 0, (max - 1), or any integer between.|
int x = randomName.nextInt(5); // x is 0, 1, 2, 3, or 4 double y = randomName.nextDouble();