Skip to content

Instantly share code, notes, and snippets.

@chids
Created February 13, 2011 13:19
Show Gist options
  • Save chids/824679 to your computer and use it in GitHub Desktop.
Save chids/824679 to your computer and use it in GitHub Desktop.
Random number within range
class RandomRange
{
private final int max;
private final int min;
public RandomRange(final int min, final int max)
{
this.min = min;
this.max = max;
}
public int next()
{
return this.min + (int)(Math.random() * ((this.max - this.min) + 1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment