List of utility methods to do Random Int
int | getRandomInt(int bound) get a random number Random random = new Random(); return random.nextInt(bound); |
int | getRandomInt(int intStart, int intEnd) get Random Int return (int) ((Math.random() * intEnd) + intStart); |
int | getRandomInt(int lower, int upper) get Random Int int num = (int) Math.floor(rand.nextDouble() * ((upper + 1) - lower)); if (num + lower > upper || num + lower < lower) { System.out.println("ERROR: Random returned value of of range!"); System.exit(1); return num + lower; |
int | getRandomInt(int lower, int upper) This method is taken from OZONE's BenchmarkImpl class if (randomGenerator == null) { randomGenerator = new Random(); randomGenerator.setSeed(1L); int value; do { value = randomGenerator.nextInt(); value %= upper; ... |
int | getRandomInt(int max) Generates next random Int Random rand = new Random(System.nanoTime()); if (max > 0) { return rand.nextInt(max); return rand.nextInt(); |
int | getRandomInt(int max) Get a random int within [0, max) range. return RANDOM.nextInt(max);
|
int | getRandomInt(int max) get Random Int if (randomGenerator.get() == null) { randomGenerator.set(new Random()); return randomGenerator.get().nextInt(max); |
int | getRandomInt(int min, int max) get Random Int Random rand = new Random(); int x = rand.nextInt(max - min + 1) + min; x = rand.nextInt(max - min + 1) + min; return x; |
int | getRandomInt(int min, int max) get Random Int if (min > max) throw new IllegalArgumentException("min > max"); if (min == Integer.MIN_VALUE && max == Integer.MAX_VALUE) { return random.nextInt(); } else { return random.nextInt(max - min + 1) + min; |
int | getRandomInt(int min, int max, Random random) Get a random int value in given range int diff = max - min + 1; int randomInt = random.nextInt(diff); return randomInt + min; |