Java Random Double randomDouble()

Here you can find the source of randomDouble()

Description

random double value between 0 and 1

License

Apache License

Declaration

public static double randomDouble() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Random;

public class Main {
    private static Random r = new Random();

    /**//from w w  w  .j a  v a2s .  c om
     * random double value between 0 and 1
     * @return
     */
    public static double randomDouble() {
        return r.nextDouble();
    }

    /**
     * random double value between begin(inclusive) and end(exclusive)  
     * @param begin
     * @param end
     * @return
     */
    public static double randomDouble(double begin, double end) {
        // (random value - 0.5) * span + middle_of_(begin,end)
        return (r.nextDouble() - 0.5) * (end - begin) + ((begin + end) / 2);
    }
}

Related

  1. randomBetween(double arg1, double arg2)
  2. randomBoth(double range)
  3. randomChance(double chance)
  4. randomColor(double d)
  5. randomDouble()
  6. randomDouble()
  7. randomDouble()
  8. randomDouble()
  9. randomDouble()