Here you can find the source of shuffleArray(int arr[])
public static int[] shuffleArray(int arr[])
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { private static Random RANDOM = new Random(System.currentTimeMillis()); public static int[] shuffleArray(int arr[]) { if (arr == null || arr.length == 0) return arr; /**/*from w ww .j av a 2s . c o m*/ * Shuffle the available columns. * Fisher-Yates shuffle a.k.a. the Knuth shuffle, modern version. */ for (int i = arr.length - 1; i >= 1; i--) { /* +1 because the n argument is exclusive */ int j = RANDOM.nextInt(i + 1); // swap a[j] and a[i] int tmp = arr[j]; arr[j] = arr[i]; arr[i] = tmp; } return arr; } }