更新时间:2023-11-23 15:43:28
打乱列表的***方法是使用标准库方法 Collections.shuffle
.
The best way to shuffle a list is using the standard library method Collections.shuffle
.
List lst = getListFromSomewhere();
Collections.shuffle(lst);
如果您想自己动手,请阅读 Fisher-Yates shuffle算法.
If you want to do it yourself, read up on the Fisher-Yates shuffle algorithm.