Here you can find the source of random(int n)
public static final int random(int n)
//package com.java2s; //License from project: Open Source License public class Main { static long state = 1; public static final int random(int n) { if (n == 1) { return 0; }/* w w w. j a v a2 s.c om*/ long r = ((nextLong() >>> 32) * n) >> 32; return (int) r; } public static final long nextLong() { long a = state; state = xorShift64(a); return a; } public static final long xorShift64(long a) { a ^= (a << 21); a ^= (a >>> 35); a ^= (a << 4); return a; } }