go to home page   go to next page hear noise

created: 07/31/2007; revised 10/22/2008, 08/26/2010, 07/05/2014

CHAPTER 20 — The Random Class

die die die die

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.

The chapter discusses:


What number is most likely outcome for a throw of a fair die?