
Line 47 defines another pattern, “00”, which is useful for printing the time
with colons between the hour, minutes, and seconds. When the time is
printed on lines 50–53, the hours, minutes, and seconds are padded with a
leading zero, if necessary.
Line 57 defines our last pattern,
“#,###”, which can be used to insert com-
mas into integer values in the thousands and above. Lines 60–61 print the
variable millions with commas separating the millions and thousands dig-
its. Notice that the pattern is extrapolated for a number that has more digits
than the pattern.
3.9 Generating Random Numbers with the Random Class
Random numbers come in handy for many operations ...