Java – Random class

Home/Java - Tutorial/Java - Packages/Java – Random class
Java – Random class 2017-06-13T00:39:54+00:00

Random class :

  • The Random class allows you to generate random double, float, int, or long numbers.
  • This can be very helpful if you are building a simulation of a real-world system.
  • This class provides the following constructors.


Random(long start)

Here, start is a value to initialize the random number generator.


Method Description
Double nextDouble() Returns a random double value.
Float nextFloat() Returns a random float value.
Double nextGaussian() Returns a random double value. Numbers obtained from repeated calls to this method have a Gaussian distribution with a mean of 0 and a standard deviation of 1.
Int nextInt() Returns a random int value.
Long nextLong() Returns a random long value.

EX :



Prev Next