The Random Utility
The random utility is used for generating a number between two specified numbers. This utility can generate ints, doubles, and longs.
Random Ints, Doubles, and Longs
Before you start using the RandomUtil, you must first import it by typing, import com.wearedevs.someclicker2.util.RandomUtil;
. After you have imported our
RandomUtil you may now type RandomUtil.
and 4 or more different options appear, depending on the code editor you are using. 3 of the options should have randomRange
as a method, and randPerc will also be an option. They will all different parameters such as, (int low, int high), (double low, double high), and so on. Select the one
that you want to use. I want to generate an int and assign it to the variable x. So, I would type:
int x = RandomUtil.randomRange(1, 10);
Just with like any other variable, I can use this anywhere I want, everytime you call this, it generates a number between 1 and 10. Of course, 1 and 10 can be any number you would like.