AP® Computer Science A glossary
Math.random
Also called: random()
Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods
A Math class method that returns a double greater than or equal to 0.0 and less than 1.0.
Appears in the course and exam description (CED): 1.11.A.21.11.A.3
To get an int from min to max inclusive, use (int) (Math.random() * (max - min + 1)) + min. Keep the parentheses: (int) Math.random() * 6 is always 0.