0 works

Generate random integers within a specific range in Java


dashboard+ Project

Posted by @starbucks #java

import java.util.concurrent.ThreadLocalRandom;

// nextInt is normally exclusive of the top value,
// so add 1 to make it inclusive
int randomNum = ThreadLocalRandom.current().nextInt(min, max + 1);
content_copyCopy to Clipboard

For use in Java 1.7 or later

https://stackoverflow.com/questions/363681/how-do-i-generate-random-integers-within-a-specific-range-in-java

>> Browse more code snippets

more_vert