Here you can find the source of getRandomInt()
public static int getRandomInt()
//package com.java2s; /**// w ww . ja v a2 s.c o m * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 2006-2011, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by * the Eclipse Foundation * * or (per the licensee's choosing) * * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ import java.util.Random; public class Main { static Random random = new Random(99807); public static int getRandomInt() { return random.nextInt(); } /** * Get a random number between 0 and u * @param u * @return */ public static int getRandomInt(int u) { if (u <= 0) { throw new IllegalArgumentException("input cannot be negative but was " + u); } return random.nextInt(u); } }