setSeed(long): This method is available in java.util.Random class of Java.
Syntax:
void java.util.Random.setSeed(long seed)
This method takes one argument. This method sets the seed of this random number generator using a single long seed.
Parameters: One parameter is required for this method.
seed: the initial seed.
Returns: NA
Exceptions: NA
Approach
Java
import java.util.Random;public class RandomsetSeed {public static void main(String[] args) {Random random = new Random();long seed = 1010010L;random.setSeed(seed);System.out.println(random.hashCode());}}
Output:
1130478920
No comments:
Post a Comment