127k views
0 votes
In order to generate a random number, you must use Math.random( ). Group of answer choices True False

User Eepp
by
5.6k points

1 Answer

5 votes

Answer:

False

Step-by-step explanation:

While Math.random() can be used to generate a random number, Java programming language also has a class called Random in the java.util package which can be imported into your code. This is a more efficient way of generating random numbers (ints or doubles) as you can instantiate several random number generators. The following line of code creates an an object of the class Random and sets the bound to 10.

Random rand = new Random (10);

This will generate random number from 0-9.

User Gmatht
by
5.5k points