/** * @author lautturi.com * Java example: Java Math.random method */ import java.util.*; public class Lautturi { public static void main(String[] args) { // generate a double value between 0.0(inclusive) to 1.0(exclusive); Math.random(); // generate a random int value between 1(inclusive) to 100 (inclusive) int randomIntNum = (int)(Math.random() * 100) + 1; // generate a random int value between 1.0(inclusive) to 100 (inclusive) double randomDoubleNum = (Math.random() * (100-1)) + 1; double randomDoubleNumx = (Math.random() * 100) + 1; // if Math.random() generate 0.9999, // it will be out of range } }Source:www.lautturi.com