Here you can find the source of rand()
public static int rand()
//package com.java2s; //License from project: Open Source License public class Main { private static long holdrand_; /**//from w ww . j av a 2 s. c o m * pseudo-random number based on linear congruential method * * @return a pseudo-random number 0 through 32767. * @see http://en.wikipedia.org/wiki/Linear_congruential_generator */ public static int rand() { holdrand_ = holdrand_ * 214013L + 2531011L; return (int) ((holdrand_ >> 16) & 0x7fff); // return (int)(randomizer.nextInt()); } }