get Range Random - Java java.util

Java examples for java.util:Random Int

Description

get Range Random

Demo Code


//package com.java2s;

public class Main {

    public static int getRangeRandom(int min, int max) {
        return (int) (Math.random() * (max - min + 1) + min);
    }//from ww w. j a v  a  2  s  . c om

    public static int getRangeRandom(int max) {
        return (int) (Math.random() * (double) max);
    }
}

Related Tutorials