Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Random;

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

    public static final int getRandom(int _min, int _max) {
        if (_min < 0 && _max < 0) {
            return randomGenerator.nextInt(Math.abs(_min - _max)) + _min;
        } else if (_min < 0) {
            return randomGenerator.nextInt(Math.abs(_min) + _max) + _min;
        } else {
            return randomGenerator.nextInt(_max - _min) + _min;
        }
    }
}