Java tutorial
//package com.java2s; import java.util.Random; public class Main { public static double getRandomDouble(double max) throws Exception { double ret; Random r = new Random(); ret = r.nextDouble() * max; return ret; } /** * Get a random double number within a given range; */ public static double getRandomDouble(double min, double max) throws Exception { double range = max - min; double ret; Random r = new Random(); ret = r.nextDouble() * range; return ret; } }