Random nextLong() in Java

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

Syntax:

long java.util.Random.nextLong()

This method returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence.

Parameters: NA

Returns: the next pseudorandom, uniformly distributed long value from this random number generator's sequence.

Exceptions: NA

Approach

Java

import java.util.Random;

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

        Random random = new Random();

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

Output:

3432238465203672251


No comments:

Post a Comment