(int)(Math.random() * (max - min) + min).

This is the formula for having value in the range min-max. The minimum number here is min and the max number is max-1.

I hope this helps.