Java Random.next(int bits)
Syntax
Random.next(int bits) has the following syntax.
protected int next(int bits)
Example
In the following code shows how to use Random.next(int bits) method.
//from www. ja 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 next pseudorandom value
int value = randomno.nextInt();
// check the value
System.out.println("Value is: " + value);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »