February 2014
Beginner
1248 pages
62h 25m
English
Figure 6.6 shows two sample outputs which confirm that the results of the preceding calculation are integers in the range 1–6, and that each run of the program can produce a different sequence of random numbers. Line 3 imports class SecureRandom from the java.security package. Line 10 creates the SecureRandom object randomNumbers to produce random values. Line 16 executes 20 times in a loop to roll the die. The if statement (lines 21–22) in the loop starts a new line of output after every five numbers to create a neat, five-column format.
Read now
Unlock full access