Here you can find the source of shuffle(Random rand, O[] array)
public static <O> void shuffle(Random rand, O[] array)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { public static <O> void shuffle(Random rand, O[] array) { for (int i = array.length - 1; i > 0; i--) { int j = rand.nextInt(i + 1); O temp = array[i];/*from w w w.j a v a 2 s . c o m*/ array[i] = array[j]; array[j] = temp; } } public static void shuffle(Random rand, short[] array) { for (int i = array.length - 1; i > 0; i--) { int j = rand.nextInt(i + 1); short temp = array[i]; array[i] = array[j]; array[j] = temp; } } /** * Method to generate an int between the lower and upper bound * * @param rand - pseudo-random number generator interface * @param low - lower bound value * @param high - upper bound value * @return an int between the lower and upper bound */ public static int nextInt(Random rand, int low, int high) { if (high < low) { throw new IllegalArgumentException("high must be greater than low"); } return rand.nextInt() * (high - low) + low; } }