0

I have problems getting random numbers to stay within a certain range. I've tried a few different suggestions, but none of them worked so far. This is the latest one I tried. Using this code generates me numbers between 0-30. But I wanna stay within 50-20.

Suggestions?

 void randomNumbersForEquation() {

        Random randomNumbers = new Random();
        int number1 = randomNumbers.nextInt(51 - 20);
        int number2 = randomNumbers.nextInt(51 - 20);
        textEasyNumber1.setText("" + number1);
        textEasyNumber2.setText("" + number2);

    }
Fisnik B.
  • 125
  • 7

0 Answers0