How To Generate a Random Number
Math.random() returns a random number between 0.0 (inclusive), and 1.0 (exclusive):
Math.random();To get more control over the random number, for example, if you only want a random number between 0 and 100, you can use the following formula:
int randomNum = (int)(Math.random() * 101); // 0 to 100Related Pages
Java Math Reference
Java Type Casting