Skip to content

Instantly share code, notes, and snippets.

@gidili
Created July 30, 2012 14:09
Show Gist options
  • Save gidili/3207120 to your computer and use it in GitHub Desktop.
Save gidili/3207120 to your computer and use it in GitHub Desktop.
Random Number Generator in java
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