nextBetween method
Generates a 32-bit bit random number between low
and high
, inclusive.
Implementation
int nextBetween(int low, int high) {
if (low == high) {
return low;
}
if (low > high) {
int t = low;
low = high;
high = t;
}
return (nextInt() % (high - low)) + low;
}