Java Math random() Method

Facebooktwitterredditpinterestlinkedinmailby feather

The random() method of Math class returns a double value with a positive sign, less than 1 and greater than or equal to 0.0. This method is properly synchronized with the correct use of one or more thread.

Syntax:

public static double random ()

Return Value:

The random() method returns a pseudorandom double value less than 1 and greater than or equal to 0.0.

 Example 1:

Output:

Example 2:

Output:

Example 3:

Output:

Example 4:

Output:

Facebooktwitterredditpinterestlinkedinmailby feather