Java Random.nextLong()
Syntax
Random.nextLong() has the following syntax.
public long nextLong()
Example
In the following code shows how to use Random.nextLong() method.
/* w ww . j a v a 2 s . c o m*/
import java.util.Random;
public class Main {
public static void main( String args[] ){
Random randomno = new Random();
// get next long value
long value = randomno.nextLong();
// check the value
System.out.println("Long value is: " + value);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »