Here you can find the source of random(int min, int max)
public static int random(int min, int max)
//package com.java2s; import java.util.*; public class Main { private static final Random random = new Random(); /**/*www.j a va 2s. co m*/ * Returns a random number */ public static int random(int min, int max) { // return ((int)(Math.random() * (1 + max - min))) + min; if (max - min == 0) { return min; } int rmin = Math.min(max, min); int rmax = Math.max(max, min); return random.nextInt(1 + rmax - rmin) + rmin; // return ((int)(random.nextFloat() * (1 + max - min))) + min; } public static float random() { return random.nextFloat(); } }