java.util.Random.nextLong() Method
Advertisements
Description
The nextLong() method is used to return the next pseudorandom, uniformly distributed long value from this random number generator's sequence.
Declaration
Following is the declaration for java.util.Random.nextLong() method.
public long nextLong()
Parameters
NA
Return Value
The method call returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence.
Exception
NA
Example
The following example shows the usage of java.util.Random.nextLong()
package com.tutorialspoint;
import java.util.*;
public class RandomDemo {
public static void main( String args[] ){
// create random object
Random randomno = new Random();
// get next long value
long value = randomno.nextLong();
// check the value
System.out.println("Long value is: " + value);
}
}
Let us compile and run the above program, this will produce the following result.
Long value is: 3285573610483682037