Java Random Int getRandomInt(Random rand, int lower, int upper)

Here you can find the source of getRandomInt(Random rand, int lower, int upper)

Description

get Random Int

License

Apache License

Declaration

public static final int getRandomInt(Random rand, int lower, int upper) 

Method Source Code


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

import java.util.Random;

public class Main {
    public static final int getRandomInt(Random rand, int lower, int upper) {
        int num = (int) Math.floor(rand.nextDouble() * (upper - lower + 1));
        return num + lower;
    }//  w w  w .j  a  v  a  2  s.  com
}

Related

  1. getRandomInt(int min, int max)
  2. getRandomInt(int min, int max, Random random)
  3. getRandomInt(int minimum, int maximum)
  4. getRandomInt(int sek, int min, int max)
  5. getRandomInt(int size)
  6. getRandomInt(String level)
  7. getRandomIntBetween(int low, int high)
  8. getRandomIntBetween(int mi, int ma)
  9. getRandomInteger(int aStart, int aEnd)