Skip to content

Instantly share code, notes, and snippets.

@Kyle-Falconer
Created October 29, 2013 13:17
Show Gist options
  • Save Kyle-Falconer/7214459 to your computer and use it in GitHub Desktop.
Save Kyle-Falconer/7214459 to your computer and use it in GitHub Desktop.
A function which returns a random int with the range [minVal, maxVal]. Code taken from ["Generating random numbers in a range with Java" on StackOverflow](http://stackoverflow.com/a/363732/940217)
public static int randRange(int minVal, int maxVal){
return minVal + (int)(Math.random() * ((maxVal - minVal) + 1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment