Example usage for java.util Random nextInt

List of usage examples for java.util Random nextInt

Introduction

In this page you can find the example usage for java.util Random nextInt.

Prototype

public int nextInt(int bound) 

Source Link

Document

Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.

Usage

From source file:Main.java

public static int getRandomInt(int min, int max) {
    Random r = new Random();
    return r.nextInt(max - min + 1) + min;
}

From source file:Main.java

public static int generateRandomNumber(int max) {
    Random rand = new Random();
    return rand.nextInt(max);
}

From source file:Main.java

public static int randomNumber(int min, int max) {
    Random rand = new Random();
    return rand.nextInt((max - min) + 1) + min;
}

From source file:Main.java

public static int random() {
    Random random = new Random();
    return random.nextInt(100) + 1;
}

From source file:Main.java

public static int getRandomRotate() {
    Random random = new Random();
    return random.nextInt(360);
}

From source file:Main.java

public static int randomIndex(int count) {
    Random random = new Random();
    return random.nextInt(count);
}

From source file:Main.java

public static <T> T chooseRandomObject(List<T> list, Random rnd) {
    return list.get(rnd.nextInt(list.size()));
}

From source file:Main.java

/**
 * Select a random number within a specified range.
 * @param min Lower limit.//from   ww  w.j a va2 s.  c o  m
 * @param max Upper limit.
 * @return int
 */
public static int getRandomInteger(int min, int max) {
    Random r = new Random();
    return r.nextInt((max - min) + 1) + min;
}

From source file:Main.java

public static int randInt(int min, int max) {

    Random random = new Random();
    return random.nextInt((max - min) + 1) + min;

}

From source file:Main.java

public static int RandomNum(int range) {
    Random random = new Random();
    int i = random.nextInt(range);
    return i;//from  w ww  .j ava  2 s.  co m
}