List of utility methods to do Random Int
int | getRandomInt(int minimum, int maximum) get Random Int int diff = maximum - minimum; if (diff == 0) { return maximum; } else { return RANDOM.nextInt(diff) + minimum; |
int | getRandomInt(int sek, int min, int max) get Random Int Random random = new Random(); int temp = 0; do { temp = random.nextInt(sek); } while (temp < min || temp > max); return temp; |
int | getRandomInt(int size) get Random Int return rand.nextInt(size + 1);
|
int | getRandomInt(Random rand, int lower, int upper) get Random Int int num = (int) Math.floor(rand.nextDouble() * (upper - lower + 1)); return num + lower; |
int | getRandomInt(String level) get Random Int if (level.contains("-")) { String[] spl = level.split("-"); return getRandomInt(Integer.parseInt(spl[0]), Integer.parseInt(spl[1])); } else return Integer.parseInt(level); |
Integer | getRandomIntBetween(int low, int high) get Random Int Between return new Random().nextInt(high - low) + low; |
int | getRandomIntBetween(int mi, int ma) get Random Int Between int n = rm.nextInt(); while (n < mi || n > ma) { n = rm.nextInt(); return n; |
int | getRandomInteger(int aStart, int aEnd) get Random Integer if (aStart > aEnd) { throw new IllegalArgumentException("Start cannot exceed End."); Random aRandom = new Random(); long range = (long) aEnd - (long) aStart + 1; long fraction = (long) (range * aRandom.nextDouble()); int randomNumber = (int) (fraction + aStart); System.out.printf("Generated : " + randomNumber); ... |
int | getRandomInteger(int min, int max) Get a random value from an interval. return min + RANDOM.nextInt(max + 1 - min);
|
Integer[] | getRandomIntegerArray(Random rand, int size, int range) get Random Integer Array Integer[] array = new Integer[size]; for (int i = 0; i < size; i++) array[i] = rand.nextInt(range); return array; |