Select a random value from an Array

前端 未结 1 1678
礼貌的吻别
礼貌的吻别 2020-12-10 06:34

I have an Array of number values, and I want to randomly select a value from in that array and then insert it in to an int variable.

I\'m not sure wha

相关标签:
1条回答
  • 2020-12-10 07:21

    Just clubsArray[new Random().nextInt(clubsArray.length)] would work

    Or to randomize the order of elements, use List<?> clubsList=Arrays.asList(clubsArray); Collections.shuffle(clubsList);.

    0 讨论(0)
提交回复
热议问题