Java Random Int generateRandomIntUpto(int max)

Here you can find the source of generateRandomIntUpto(int max)

Description

generate Random Int Upto

License

Apache License

Return

random int between 0 and max-1. e.g. param of 10 returns 0->9

Declaration

public static int generateRandomIntUpto(int max) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Random;

public class Main {
    public static final Random RANDOM = new Random(System.currentTimeMillis());

    /**//w ww.j  av a  2  s .c o m
     * @return random int between 0 and max-1. e.g. param of 10 returns 0->9
     */
    public static int generateRandomIntUpto(int max) {
        return nextInt(max);
    }

    public static int nextInt(int n) {
        return RANDOM.nextInt(n);
    }

    public static int nextInt() {
        return RANDOM.nextInt();
    }
}

Related

  1. generateRandomIntegerArray(int size, int min, int max)
  2. generateRandomIntegers(int numbersNeeded, int bound)
  3. generateRandomIntInRange(int min, int max)
  4. generateRandomIntObj(int range, int noOfElements)
  5. generateRandomInts(int range, int noOfElements)
  6. generateRandomIntValue()
  7. generateRandomNoInRange(int max, int min)
  8. generateRandomSeed(int min, int max)
  9. generateRandomTargetId(final String uniqueId, final int count)