Java Math.random method

Java Math.random method
/**
 * @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
	}
}
Sour‮‬ce:www.lautturi.com
Created Time:2017-10-04 15:44:23  Author:lautturi