Java Random Double randomChance(double chance)

Here you can find the source of randomChance(double chance)

Description

generates a random output based on a chance

License

Open Source License

Parameter

Parameter Description
chance chance for a true result (between 0 and 1, automatically clamped)

Declaration

public static boolean randomChance(double chance) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   ww w.  j a v  a2  s . c  o  m*/
     * generates a random output based on a chance
     * @param chance chance for a true result (between 0 and 1, automatically clamped)
     */
    public static boolean randomChance(double chance) {
        return Math.random() < chance;
    }
}

Related

  1. random(double min, double max)
  2. random(double min, double max)
  3. random(final double min, final double max)
  4. randomBetween(double arg1, double arg2)
  5. randomBoth(double range)
  6. randomColor(double d)
  7. randomDouble()
  8. randomDouble()
  9. randomDouble()