代码实现
public static void main(String[] args) {
int arr[] = new int[] {4,56,1,6,23,64};
arr = disrupt(arr);
for(int m:arr) {
System.out.print(m+" ");
}
}
public static int[] disrupt(int arr[]) {
int arrTemp[] = new int[arr.length];
int size = arr.length-1;
Random rd = new Random();
for(int i = 0 ; i < arr.length ; i++) {
int rand = rd.nextInt(size+1);
arrTemp[i] = arr[rand];
arr[rand] = arr[size];
size--;
}
return arrTemp;
}
```