Random nextInt() in Java

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

Syntax:

int java.util.Random.nextInt()

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

Parameters: NA

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

Exceptions: NA

Approach

Java

import java.util.Random;

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

        Random random = new Random();

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

Output:

2056763809


No comments:

Post a Comment