Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Random;
- public class FixedRandom {
- public static void main(String[] args) {
- long seed = 2017L;
- List<Integer> xs = new Random(seed).ints(20, 0, 19).collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
- System.out.println(xs);
- Random r = new Random(seed);
- List<Integer> ys = new ArrayList<>();
- for (int i = 0; i < 20; ++i) {
- ys.add(r.nextInt(19));
- }
- System.out.println(ys);
- Random r2 = new Random(seed);
- int[] zs = new int[20];
- for (int i = 0; i < zs.length; ++i) {
- zs[i] = r2.nextInt(19);
- }
- System.out.println(Arrays.toString(zs));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement