Here you can find the source of permute(Random random, ArrayList array)
public static void permute(Random random, ArrayList array)
//package com.java2s; import java.util.ArrayList; import java.util.Random; public class Main { public static void permute(Random random, ArrayList array) { for (int i = 0; i < array.size(); i++) { int j = i + random.nextInt(array.size() - i); Object tmp = array.get(i); array.set(i, array.get(j));//from w w w. jav a 2 s.co m array.set(j, tmp); } } }