Skip to content

Commit ddbd004

Browse files
committed
Add RandomTools class and betweenTwoIntegers function
1 parent a7b7bec commit ddbd004

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package parallelmc.parallelutils.util;
2+
3+
import java.util.Random;
4+
5+
/**
6+
* A helper class for functions related to obtaining random values
7+
*/
8+
public class RandomTools {
9+
10+
/**
11+
* Calculates a random integer between two integer values
12+
* @param low The first integer
13+
* @param high The second integer
14+
* @return The random integer between low (inclusive) and high (exclusive)
15+
* For example, if low = 3 and high = 6, possible results could be 3, 4, or 5
16+
*/
17+
public static int betweenTwoIntegers(int low, int high) {
18+
Random r = new Random();
19+
return r.nextInt(high-low) + low;
20+
}
21+
}

0 commit comments

Comments
 (0)