Here you can find the source of getRandomInt(int bound)
Parameter | Description |
---|---|
bound | the upper bound (exclusive). Must be positive. |
public static int getRandomInt(int bound)
//package com.java2s; //License from project: Apache License import java.util.Random; public class Main { /**/* w w w. j ava 2s. co m*/ * get a random number * * @param bound the upper bound (exclusive). Must be positive. * @return an {@code int} value between zero (inclusive) and {@code bound} (exclusive) */ public static int getRandomInt(int bound) { Random random = new Random(); return random.nextInt(bound); } }