Java Random Int randomNumberWithinRange(int min, int max)

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

Description

Returns a random number within the given range.

License

Open Source License

Parameter

Parameter Description
min The minimum value
max The maximum value

Return

The random number

Declaration

static Integer randomNumberWithinRange(int min, int max) 

Method Source Code

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

public class Main {
    /**// w ww  .jav a 2s. co  m
     * Returns a random number within the given range.
     *
     * @param min The minimum value
     * @param max The maximum value
     * @return The random number
     */
    static Integer randomNumberWithinRange(int min, int max) {
        return ((int) (Math.random() * max)) + min;
    }
}

Related

  1. randomNumber(int lower_bound, int higher_bound)
  2. randomNumber(int min, int max)
  3. randomNumber(int minimum, int maximum)
  4. randomNumberBetweenIntervals(int min, int max)
  5. randomNumberWithinRange(int low, int high)
  6. randomPass(int n)
  7. randomPointInConvexPoly(float[] pts, int npts, float[] areas, float s, float t)
  8. randomPointsFromFigureEight(int n)
  9. randomPointsFromUnitSphere(int n)