Example usage for java.lang Math random

List of usage examples for java.lang Math random

Introduction

In this page you can find the example usage for java.lang Math random.

Prototype

public static double random() 

Source Link

Document

Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0 .

Usage

From source file:Main.java

public static float random(float min, float max) {
    return (float) (Math.random() * (max - min) + min);
}

From source file:Main.java

public static int numRandom(int mixNum, int _num) {
    return (int) (Math.random() * _num);
}

From source file:Main.java

public static int getRandom(int min, int max) {
    return min + (int) (Math.random() * ((max - min) + 1));
}

From source file:Main.java

public static int getRandomNum(int mixNum, int _num) {
    return (int) (Math.random() * _num);
}

From source file:Main.java

public static int get1NumRange2(int start, int end) {
    return (int) (Math.random() * (end - start) + start);
}

From source file:Main.java

private static char getRandomNumChar() {
    return (char) (0x30 + (int) (Math.random() * (0x39 - 0x30 + 1)));
}

From source file:Main.java

private static int getRandom(int range) {
    return (int) (Math.round(range * Math.random()));
}

From source file:Main.java

public static int getPositon(int height) {
    int tempPositoin = (int) (Math.random() * height);
    if (tempPositoin < 30) {
        tempPositoin += 30;/*from   w  w w  .  j  a va2 s  .  c o  m*/
    }
    return tempPositoin;
}

From source file:Main.java

public static int getRandom(int min, int max) {
    int ret = (int) Math.floor(Math.random() * (max - min + 1)) + min;
    return ret;//  w w w .  j a  v  a  2 s . c  o  m
}

From source file:Main.java

public static int getPositon(int height) {
    int tempPositoin = (int) (Math.random() * height);
    if (tempPositoin < 15) {
        tempPositoin += 15;//  ww  w .  j a va2 s.  com
    }
    return tempPositoin;
}