Java tutorial
//package com.java2s; import java.util.*; public class Main { public static <E> void shuffleInPlace(E[] elems, Random rand) { for (int j = elems.length - 1; j > 0; j--) { int randIndex = rand.nextInt(j + 1); E tmp = elems[randIndex]; elems[randIndex] = elems[j]; elems[j] = tmp; } } }