Developers notes
Programming Tips&Tricks
Monday, July 27, 2015
Generating random integers in a range
Random rand;
int randomNum = rand.nextInt((max - min) + 1) + min;
or
int randomNum = ThreadLocalRandom.current().nextInt(min, max + 1);
Ref:
stackoverflow - Generating random integers in a range with Java
Random - nextInt
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment