Check out example codes for "how to create a random number in java". It will help you in understanding the concepts better.

Code Example 1

double x = (Math.random()*((max-min)+1))+min;

Code Example 2

import java.util.Random;

Random rand = new Random();

// Obtain a number between [0 - 49].
int n = rand.nextInt(50);

// Add 1 to the result to get a number from the required range
// (i.e., [1 - 50]).
n += 1;

Code Example 3

import java.util.Random;

class scratch{
    public static void main(String[] args) {
        Random rand = new Random();
        System.out.println( rand.nextInt(5) );
        //prints a random Int between 0 - 4 (including 0 & 4);
    }
}

Code Example 4

public class GuessTheNumber {
  public static void main(String[] args) {
    
    
    int randomInt = (int)(20.0 * Math.random());
    int num1 = randomInt;
    int num2 = 10;
    
    if(num1 == num2){
    	System.out.println("Correct!");
    } else if(num1 > num2){
    	System.out.println("Too low!");
    } else{
    	System.out.println("Too high!");
    }
    
    
  }
}

Learn ReactJs, React Native from akashmittal.com