Here you can find the source of getRandomNumber(int bound)
Parameter | Description |
---|---|
bound | specifies the interval from which to chose the number |
public static int getRandomNumber(int bound)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { public final static Random RANDOM = new Random(); /**/*w w w. j a va 2 s . co m*/ * Produces a random number in the interval (-bound, bound) * @param bound specifies the interval from which to chose the number * @return a random number in the interval (-bound, bound) */ public static int getRandomNumber(int bound) { return (RANDOM.nextInt(1) * 2 - 1) * RANDOM.nextInt(bound); } }