I'm using Random() to generate a number between this year-5 and this year-1. As of (20) 19, this means between 14 and 18. But, for some reason, my code includes 19 in the random range.
I'm running the below code below (the line that does the generating) 10 times, and here's the output:
14
18
14
16
16
19
15
19
15
16
The code:
Random randomizer = new Random();
//(USING HARD-CODED MIN-MAX VALUES FOR TESTING)
int max = 18;
int min = 14;
String syear = Integer.toString(randomizer.nextInt((max + 1 - min) + 1) + min);
Any and all help is appreciated!
Aucun commentaire:
Enregistrer un commentaire