how to assign random numbers in java code example
Example 1: java random number
import java.util.Random;
Random rand = new Random();
int n = rand.nextInt(50);
n += 1;
Example 2: generate random number in java
import java.lang.Math;
int randomNumber;
int minimum = 1;
int maximum = 10 - minimum;
randomNumber = (int)((Math.random()*maximum) + minimum);
System.out.println("Random Number (Between 1-10): " + randomNumber);
Example 3: how to generate random number in java
double x = (Math.random()*((max-min)+1))+min;