mardi 4 mai 2021

Generate only not generated random numbers in a certain range android studio?

Hi in my Android application I need to generate all numbers(not together but when I call the function say generateAnyRandom()) in a certain range.

For example, say my range is 1 to 1000 and when I call generateAnyRandom() it should give a random number within the range. In this way, if again I call the function it should give me another random number which must be different from the existing one. And more importantly, I will call the function maximum of 1000 times as the range is 1 to 1000 and it should give me always a number that was not generated yet. That means I want to generate all the numbers from 1 to 1000 not in one shot but only when I call it.

Please help. It is a critical question for me?




Aucun commentaire:

Enregistrer un commentaire