samedi 13 avril 2019

How to randomly pick four elements from an array without repeating in Java?

Let's say fruitsArray = ["apple", "orange", "pear", "banana", "cherry", "blueberry", "papaya", "litchi"].

How to randomly pick four elements from this array without repeating?

Example result would be ["orange", "pear","blueberry","litchi"]
while result like ["apple", "orange","orange","papaya"] is not acceptable.




Aucun commentaire:

Enregistrer un commentaire