Java Random.nextInt(int n)
Syntax
Random.nextInt(int n) has the following syntax.
public int nextInt(int n)
Example
In the following code shows how to use Random.nextInt(int n) method.
//w w w . j a va2s . co m
import java.util.Random;
public class Main {
public static void main( String args[] ){
Random randomno = new Random();
// check next int value
System.out.println("Next int value: " + randomno.nextInt(10000));
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »