/* * This example source code demonstrates the use of * Random() method of Math class * Generating random numbers from 1 to 10 */ public class RandomeNum{ public static void main(String[] args) { // define the range int max = 10; int min = 1; int range = max - min + 1; // generate random number from 1 to 10 int rand = (int) (Math.random()* range) + min; System.out.println(rand); } }