Here you can find the source of permute(T[] values)
public static <T> T[] permute(T[] values)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { /**//from w w w . j a va 2 s . c om * A random number generator for use in permutations and such. */ static Random generator = new Random(); /** * "Randomly" permute an array in place. */ public static <T> T[] permute(T[] values) { for (int i = 0; i < values.length; i++) { swap(values, i, generator.nextInt(values.length)); } // for return values; } /** * Swap two elements in an array. * * @param values, the array * @param i, one of the indices * @param j, another index * @pre 0 <= i,j < values.length * @pre a = values[i] * @pre b = values[j] * @post values[i] = b * @post values[j] = a */ public static <T> void swap(T[] values, int i, int j) { T tmp = values[i]; values[i] = values[j]; values[j] = tmp; } }