Created
July 30, 2012 14:09
-
-
Save gidili/3207120 to your computer and use it in GitHub Desktop.
Random Number Generator in java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class RandomNumberGenerator { | |
public static final int MIN = 0; | |
public static final int MAX = 1000000; | |
public static int GenerateRandomNumber(){ | |
Random rand = new Random(); | |
// nextInt is normally exclusive of the top value, | |
// so add 1 to make it inclusive | |
int randomNum = rand.nextInt(MAX - MIN + 1) + MIN; | |
return randomNum; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment