Generating Random Numbers

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

Figure 546. Seeding a pseudo random generator Slide presentation
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