go to previous page   go to home page   go to next page hear noise

Answer:

Yes. Use the nextBoolean() method, described below, or use nextInt(2).


More Random Methods

Here are some more methods of the Random class:

long nextLong() — Returns a pseudorandom, uniformly distributed long value.
All possible long values, both positive and negative, are in the range of values returned.
boolean nextBoolean() — Returns a pseudorandom boolean value.
void setSeed(long seed) — sets the seed of the random number generator.
This might be done in several places in a program so that different objects are tested against
the same random events.

There are some other methods of Random not described here.


QUESTION 13:

Think of a really great secret password for your computer account.