Programs frequently need random numbers.
A card game uses random numbers to create a shuffled deck of cards.
A dice game uses random numbers to simulate a throw.
Many activities in the real world
(such as traffic on a highway system, or raindrops on a sidewalk)
appear to be random, and a program that models them must use random numbers.
This chapter discusses the
Random class that comes with Java.
Random numbers, probability, and statistics are important for testing, for modeling the world, and for a general understanding of the universe. Computer science degree programs usually require a course in these subjects.
What number is most likely outcome for a throw of a fair die?