Java Random Int randomIntFromRange(int min, int max)

Here you can find the source of randomIntFromRange(int min, int max)

Description

Generates random int value from the specified range of int numbers

License

Open Source License

Parameter

Parameter Description
min minimum number in range
max maximum number in range

Return

random int value from range of [min, max]

Declaration

public static int randomIntFromRange(int min, int max) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   ww  w.  ja v a 2 s.  co  m*/
     * Generates random int value from the specified range of int numbers
     *
     * @param min minimum number in range
     * @param max maximum number in range
     * @return random int value from range of [min, max]
     */
    public static int randomIntFromRange(int min, int max) {
        return min + (int) (Math.random() * ((max - min)));
    }
}

Related

  1. RandomInteger()
  2. randomInteger(final int upperRange)
  3. randomInteger(int low, int high)
  4. randomInteger(int min, int max)
  5. randomIntFromInterval(int min, int max)
  6. randomIntInInterval(int lower, int upper)
  7. randomIntInRange(int lowerBound, int upperBound)
  8. randomIntRange(int low, int high)
  9. randomIntWithDigits(int digits)