Here you can find the source of shuffleArray(int[] ar)
public static int[] shuffleArray(int[] ar)
//package com.java2s; //License from project: Apache License import java.util.Random; import java.util.concurrent.ThreadLocalRandom; public class Main { public static int[] shuffleArray(int[] ar) { // If running on Java 6 or older, use `new Random()` on RHS here Random rnd = ThreadLocalRandom.current(); for (int i = ar.length - 1; i > 0; i--) { int index = rnd.nextInt(i + 1); // Simple swap int a = ar[index]; ar[index] = ar[i];//from w w w .ja v a 2 s .com ar[i] = a; } return ar; } }