Random Numbers Flashcards
can computers generate truly random numbers
no only sort of random, psuedo random ones
in java how do you create a random number generator
importing the random library
import random library line
import java.util.Random
create random number line
Random generator = newRandom();
to create a random number generator with a seed
Random generator = new Random ();
what is a seed
a place where the numbers are derived from
generate a random integer
integer randomInt = generator.nextInt();
generate a random double
double randomDouble = generator.nextDouble();
generate a random boolean
boolean randomBoolean = generator.nextBoolean();
to generate a random integer in a specified range, in this case 100
integer randomInt = generator.nextInt(100);
what are the possible integers in this range
integer randomInt = generator.nextInt(100);
0-99 inclusive