get Random Int - Java java.util

Java examples for java.util:Random Int

Description

get Random Int

Demo Code


//package com.java2s;

public class Main {
    public static int getRandomInt() {
        return getRandomInt(1, Integer.MAX_VALUE);
    }/*  w w  w  .jav  a 2 s  .  c o  m*/

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

Related Tutorials