[Solved] Why is Random.nextInt() and Math.random going out of the range I set? [duplicate]


Think about this part:

random.nextInt(75) + 25

You’re generating a number between 0 and 74, then adding 25. This generates a random number from 25 to 99. If it generates 74 and you add 25, it becomes 99.

You need to subtract the lower bound before generating:

random.nextInt(75 - 25) + 25)

2

solved Why is Random.nextInt() and Math.random going out of the range I set? [duplicate]