Here you can find the source of random(int maxValue)
public static int random(int maxValue)
//package com.java2s; //License from project: Open Source License public class Main { public static int random(int maxValue) { return (int) (Math.random() * (maxValue + 1)); }//w ww . j a v a 2 s. c om public static float random(float maxValue) { return (float) (Math.random() * maxValue); } public static double random(double maxValue) { return Math.random() * maxValue; } public static int random(int minValue, int maxValue) { return (int) (Math.random() * (maxValue - minValue + 1)) + minValue; } public static float random(float minValue, float maxValue) { return (float) (Math.random() * (maxValue - minValue)) + minValue; } public static double random(double minValue, double maxValue) { return Math.random() * (maxValue - minValue) + maxValue; } }