Java Random Int random(int x)

Here you can find the source of random(int x)

Description

Returns a random real number between 0 and x.

License

Open Source License

Parameter

Parameter Description
x The maximum range

Return

A random real number

Declaration

public static int random(int x) 

Method Source Code

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

public class Main {
    /**/*w  ww. ja  v  a  2s .c  o m*/
     * Returns a random real number between 0 and x. The number is always
     * smaller than x.
     *
     * @param x The maximum range
     * @return A random real number
     */
    public static int random(int x) {
        return (int) (Math.floor(Math.random() * x));
    }
}

Related

  1. random(int n)
  2. random(int numSamples)
  3. random(int range)
  4. random(int start, int end)
  5. random(int theRange)
  6. random(int... array)
  7. random_range(int x1, int x2)
  8. randomActorId(int max)
  9. randomAlphaNum(int length)