Generating Random Numbers

Figure 531. Using static double random​() Slide presentation Create comment in forum
for (int i = 0; i < 10; i++) {
  System.out.println(Math.random());
}
0.4754286988826202
0.0060114391743414375
...
0.9047785351372987
0.2516070321935864

Figure 532. Seeding a pseudo random generator Slide presentation Create comment in forum
try(final Scanner scanner = new Scanner(System.in)) {
  System.out.print("Enter an integer seed:");
  final long seed = scanner.nextLong();

  Random generator = new Random(seed);
  for (int i = 0; i < 10; i++) {
    System.out.print(generator.nextBoolean() + " ");
  }
}
Enter an integer seed:4237549835735
false true true true false false false true false true