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 gteRandomColor() {
    Random random = new Random();
    return Color.rgb(random.nextInt(200) + 20, random.nextInt(200) + 20, random.nextInt(200) + 20);
}

From source file:Main.java

public static int nextInt(int lower, int upper) {
    Random ra = new Random();
    return (lower + ra.nextInt(upper - lower + 1));
}

From source file:Main.java

public static int randomColor() {
    Random random = new Random();
    int red = random.nextInt(150) + 50;
    int green = random.nextInt(150) + 50;
    int blue = random.nextInt(150) + 50;
    return Color.rgb(red, green, blue);
}

From source file:Main.java

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

From source file:Main.java

public static int getRandom(int min, int max) {
    if (max == min) {
        min = 0;//from   w  w w.ja v  a  2  s .  co  m
        max = 100;
    }
    Random random = new Random();

    return random.nextInt(max) % (max - min + 1) + min;
}

From source file:Main.java

public static int randomColor() {
    Random random = new Random();
    int red = random.nextInt(150) + 50;//50-199
    int green = random.nextInt(150) + 50;//50-199
    int blue = random.nextInt(150) + 50;//50-199
    return Color.rgb(red, green, blue);
}

From source file:Main.java

public static int getRandomNumber(int[] randomNumber) {
    int length = randomNumber.length;
    Random ran = new Random();
    return randomNumber[ran.nextInt(length)];
}

From source file:Main.java

public static int getRandomNumber() {
    Random random = new Random();
    int num = random.nextInt(100);
    return num;/*from w w  w. j av a2  s.  c om*/
}

From source file:Main.java

public static long nextLong(int lower, int upper) {
    Random ra = new Random();
    int n = lower + ra.nextInt(upper - lower);
    long m = ra.nextLong();
    return n + m;
}

From source file:Main.java

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