Java Random nextGaussian() Method

The nextGaussian() method of Random class returns the next pseudorandom, Gaussian(normally) distributed double value with mean 0.0 and standard deviation 1.0 from the random number generator's sequence.

Syntax

Parameters

NA

Return Value

The nextDouble() method returns the next pseudorandom Gaussian distributed double number with mean 0.0 and standard deviation 1.0.

Example 1

Output:

Random Gaussian value : -3.3518483633913014
Random Gaussian value : -1.3767908077736486

Example 2

Test it Now

Output:

-0.7001112567605307 
-1.0015898772831247 
-0.8454172962601406 
0.12805541404557777 
-0.8336655342786383

Example 3

Test it Now

Output:

Enter the number of Visitors.4
Enter the name of 4 students.
1 Reema
2 Ravi
3 Rahul
4 Sonia
Sorry! Reema you are out of the game.
Congratulations! Ravi you are in the game.
Sorry! Rahul you are out of the game.
Sorry! Sonia you are out of the game.