Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

oracle.adfnmc.java.util
Class Random

java.lang.Object
  extended by oracle.adfnmc.java.util.Random
All Implemented Interfaces:
Serializable

public class Random
extends java.lang.Object
implements Serializable

This class provides methods that generates pseudo-random numbers of different types, such as int, long, double and float using either

See Also:
Properties, PropertyResourceBundle

Constructor Summary
Random()
          Construct a random generator with the current time of day in milliseconds as the initial state.
Random(long seed)
          Construct a random generator with the given seed as the initial state.
 
Method Summary
protected  int next(int bits)
          Returns a pseudo-random uniformly distributed int value of the number of bits specified by the argument bits.
 boolean nextBoolean()
          Answers the next pseudo-random, uniformly distributed boolean value generated by this generator.
 void nextBytes(byte[] buf)
          Modifies the byte array by a random sequence of bytes generated by this random number generator.
 double nextDouble()
          Generates a normally distributed random double number between 0.0 inclusively and 1.0 exclusively.
 float nextFloat()
          Generates a normally distributed random float number between 0.0 inclusively and 1.0 exclusively.
 double nextGaussian()
          Returns a pseudo-randomly generated, normally distributed double value with mean 0.0 and a standard deviation value of 1.0.
 int nextInt()
          Generates a uniformly distributed 32-bit int value from the this random number sequence.
 int nextInt(int n)
          Returns a new pseudo-random integer value which is uniformly distributed between 0 (inclusively) and n (exclusively).
 long nextLong()
          Generates a uniformly distributed 64-bit int value from the this random number sequence.
 void setSeed(long seed)
          Modifies the seed using a linear congruential formula, as found in The Art of Computer Programming, Volume 2, by Donald E.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Random

public Random()
Construct a random generator with the current time of day in milliseconds as the initial state.

See Also:
setSeed(long)

Random

public Random(long seed)
Construct a random generator with the given seed as the initial state.

Parameters:
seed - the seed that will determine the initial state of this random number generator
See Also:
setSeed(long)
Method Detail

next

protected int next(int bits)
Returns a pseudo-random uniformly distributed int value of the number of bits specified by the argument bits. Implements D. H. Lehmer's random number algorithm found in The Art of Computer Programming, Volume 2: Seminumerical Algorithms, by Donald E. Knuth (section 3.2.1).

Parameters:
bits - number of bits of the returned value
Returns:
a pseudo-randomly generated int
See Also:
nextBytes(byte[]), nextDouble(), nextFloat(), nextInt(), nextInt(int), nextGaussian(), nextLong()

nextBoolean

public boolean nextBoolean()
Answers the next pseudo-random, uniformly distributed boolean value generated by this generator.

Returns:
boolean a pseudo-random, uniformly distributed boolean value

nextBytes

public void nextBytes(byte[] buf)
Modifies the byte array by a random sequence of bytes generated by this random number generator.

Parameters:
buf - non-null array to contain the new random bytes
See Also:
next(int)

nextDouble

public double nextDouble()
Generates a normally distributed random double number between 0.0 inclusively and 1.0 exclusively.

Returns:
a random double between 0.0 and 1.0
See Also:
nextFloat()

nextFloat

public float nextFloat()
Generates a normally distributed random float number between 0.0 inclusively and 1.0 exclusively.

Returns:
a random float between 0.0 and 1.0
See Also:
nextDouble()

nextGaussian

public double nextGaussian()
Returns a pseudo-randomly generated, normally distributed double value with mean 0.0 and a standard deviation value of 1.0. Implements G. E. P. Box, M. E. Muller, and G. Marsaglia's polar method found in The Art of Computer Programming, Volume 2: Seminumerical Algorithms, by Donald E. Knuth (section 3.4.1).

Returns:
a pseudo-randomly generated double
See Also:
nextDouble()

nextInt

public int nextInt()
Generates a uniformly distributed 32-bit int value from the this random number sequence.

Returns:
a randomly generated int
See Also:
Integer.MAX_VALUE, Integer.MIN_VALUE, next(int), nextLong()

nextInt

public int nextInt(int n)
Returns a new pseudo-random integer value which is uniformly distributed between 0 (inclusively) and n (exclusively).

Parameters:
n - the upper limit of the values that can be returned
Returns:
a randomly generated int between 0 and n

nextLong

public long nextLong()
Generates a uniformly distributed 64-bit int value from the this random number sequence.

Returns:
64-bit int random number
See Also:
Integer.MAX_VALUE, Integer.MIN_VALUE, next(int), nextInt(), nextInt(int)

setSeed

public void setSeed(long seed)
Modifies the seed using a linear congruential formula, as found in The Art of Computer Programming, Volume 2, by Donald E. Knuth (section 3.2.1).

Parameters:
seed - the seed that alters the state of the random number generator
See Also:
next(int), Random(), Random(long)

Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.