Java Random Int random(int lo, int hi)

Here you can find the source of random(int lo, int hi)

Description

Answer a (pseudo-)random integer lo <= x < hi Creation date: (08.10.2002 20:34:42)

License

Open Source License

Parameter

Parameter Description
low int
up int

Return

int

Declaration

public static int random(int lo, int hi) 

Method Source Code

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

public class Main {
    /**/*  w w w .j  a v a  2  s. c  om*/
     * Answer a (pseudo-)random integer lo <= x < hi
     * Creation date: (08.10.2002 20:34:42)
     * @return int
     * @param low int
     * @param up int
     */
    public static int random(int lo, int hi) {
        int len = hi - lo;
        int x = (int) (Math.random() * len);

        return lo + x;
    }
}

Related

  1. Random(int a, boolean Zero)
  2. random(int length)
  3. random(int length)
  4. random(int length, String data)
  5. random(int limit)
  6. Random(int low, int high)
  7. random(int lowerBound, int upperBound)
  8. random(int maxValue)
  9. random(int min, int max)