Java Random.setSeed(long seed)
Syntax
Random.setSeed(long seed) has the following syntax.
public void setSeed(long seed)
Example
In the following code shows how to use Random.setSeed(long seed) method.
import java.util.Random;
// www.ja v a 2 s . co m
public class Main {
public static void main( String args[] ){
Random randomno = new Random();
// setting seed
randomno.setSeed(20);
// value after setting seed
System.out.println("Object after seed: " + randomno.nextInt());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »