/** * @author lautturi.com * Java example:generate random number between 1 and 10 using math.random in java */ import java.util.*; public class Lautturi { public static void main(String[] args) { // generate a double value between 0.0(inclusive) to 1.0(exclusive); Math.random(); // generate a random number between 1 to 10; double randomNum = Math.floor(Math.random() * 10) + 1; System.out.println(randomNum); } }Source:www.lautturi.com