dimanche 30 octobre 2016

Random number generator in java

I am trying to make a random number generator that will generate either a 1 or a 2. However whenever I run the program only a 0 is printed. This is what I have right now:

Random rand = new Random();
int  n = rand.nextInt(2) + 1;
System.out.println(n);




Aucun commentaire:

Enregistrer un commentaire