Check out example codes for "random number in range java". It will help you in understanding the concepts better.

Code Example 1

(int)(Math.random() * ((max - min) + 1)) + min
Copy

Code Example 2

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);

Code Example 3

int rand = ThreadLocalRandom.current().nextInt(x,y);

Learn ReactJs, React Native from akashmittal.com