This is a simple method for generating a random number between zero (0) and a given number.
The following code example with generate a random number between 0 and 49.
Although the value of maxNumber is set to 50, Java will start the count at 0.
If you want a number between 0 and 50, set the value of maxNymber to 51.
int maxNumber = 50;
int randomNumber = (int)Math.floor(Math.random() * maxNumber);