vendredi 11 août 2017

Does Collections.shuffle() randomize list in place?

List<String> list = new ArrayList<>();
...
Collections.shuffle(list);

shuffle return void, does that mean the parameter 'list' is changed internally, i.e. after the call, 'list' is already randomized? This sounds like a good way to get a random sample of a collection. Normally, I don't have to write my own randomize function. Isn't it?




Aucun commentaire:

Enregistrer un commentaire