Here you can find the source of shuffleList(List
public static void shuffleList(List<Integer> list)
//package com.java2s; //License from project: Open Source License import java.util.Collections; import java.util.List; import java.util.Random; public class Main { /**/*from ww w .j ava 2 s.com*/ * Shuffles the input list using an implementation of the Knuth "Algorithm P" shuffle. * * This algorithm produces a random permutation of the elements * in the input list. See Introduction to Algorithms page 127 for proof. */ public static void shuffleList(List<Integer> list) { Random randomGenerator = new Random(); for (int loopIndex = list.size() - 1; loopIndex > 0; loopIndex--) { int randomIndex = randomGenerator.nextInt(loopIndex + 1); Collections.swap(list, randomIndex, loopIndex); } } }