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