Random nextDouble() in Java

nextDouble(): This method is available in java.util.Random class of Java.

Syntax:

double java.util.Random.nextDouble()

This method returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.

Parameters: NA

Returns: the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.

Exceptions: NA

Approach

Java

import java.util.Random;

public class RandomnextDouble {
    public static void main(String[] args) {

        Random random = new Random();

        System.out.println(random.nextDouble());
    }
}

Output:

0.04647506829843728


No comments:

Post a Comment