Java tutorial
//package com.java2s; import java.util.Random; public class Main { /** * Get a random double number from 0 to 10. * * @return */ public static double getRandomValue() { return getRandomValue(0, 10); } /** * Get a random double number from min to max. * * @param min * the minimum value * @param max * the maximum value * @return */ public static double getRandomValue(double min, double max) { Random r = new Random(); return ((int) (10000 * ((r.nextDouble() * (max - min)) + min))) / 10000.0; } }