Java – Random class

Java – Random class 2017-08-09T12:21:31+00:00

Java 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.

Java Random Class example program :



Prev Next