Random longs() in Java

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

Syntax:

LongStream java.util.Random.longs()

This method returns an effectively unlimited stream of pseudorandom long values.

Parameters: NA

Returns: a stream of pseudorandom long values.

Exceptions: NA

Approach

Java

import java.util.Random;

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

        Random random = new Random();

        System.out.println(random.longs().count());
    }
}

Output:

9223372036854775807


No comments:

Post a Comment