参考链接
听说过 java.utils.Random 随机数是伪随机,但是Math库还没学,所以下面代码中还是用的Random
public static int[] shuffle(int[] arr){
Random r = new Random();
for (int i = 1; i < arr.length; i++) {
int tmpInt = arr[arr.length-i];
int randomIndex = r.nextInt(arr.length - i);
arr[arr.length-i] = arr[randomIndex];
arr[randomIndex] = tmpInt;
}
return arr;
}
标签:arr,java,--,打乱,Random,int,length,randomIndex
From: https://www.cnblogs.com/hack2xia/p/16916844.html