Java examples for java.util:Random Int
Generate new non zero random number.
// Copyright (C) GridGain Systems, Inc. Licensed under GPLv3, http://www.gnu.org/licenses/gpl.html //package com.java2s; import java.util.*; public class Main { /** Random numbers generator. */ static final Random rand = new Random(); /**//from w w w . j av a 2 s. c om * Generate new non zero random number. * * @param bound Bound of the random number. * @return Non zero random number. */ static int getRand(int bound) { int num = rand.nextInt(bound); return (num != 0) ? num : getRand(bound); } }