android: generate random number without repetition

后端 未结 4 2011
隐瞒了意图╮
隐瞒了意图╮ 2021-01-07 00:03

can anybody help me in making a method to generate random number without repetition in Android? The maximum number is: prjcts.size(); it\'s my JSON Array. And t

4条回答
  •  独厮守ぢ
    2021-01-07 00:16

    For what its worth, you could try using the Mersenne Twister algorithm, which has a Java implementation of it here. The Mersenne Twister is a random number generator which has a period of 2^19937 − 1, so you're pretty much guaranteed to not get the same random number.

提交回复
热议问题