Java Random String Shuffle(ArrayList list, Random randomNumberGenerator)

Here you can find the source of Shuffle(ArrayList list, Random randomNumberGenerator)

Description

This method randomly shuffles a list of String objects.

License

Open Source License

Parameter

Parameter Description
list List of String objects
randomNumberGenerator Random number generator that will be used for shuffling

Return

Shuffled list

Declaration

public static ArrayList<String> Shuffle(ArrayList<String> list, Random randomNumberGenerator) 

Method Source Code


//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.util.*;

public class Main {
    /** This method randomly shuffles a list of String objects.
     */*w  w w . j a  v a 2  s. c om*/
     * @param list List of String objects
     * @param randomNumberGenerator Random number generator that will be used for shuffling
     * @return Shuffled list
     */
    public static ArrayList<String> Shuffle(ArrayList<String> list, Random randomNumberGenerator) {
        ArrayList<String> shuffled = new ArrayList<String>(list);

        Collections.shuffle(shuffled, randomNumberGenerator);

        return shuffled;
    }
}

Related

  1. randomString(Integer len)
  2. randomString(Random r, int minCount, int maxCount)
  3. randomSubset(String[] list, int count)
  4. randomSuffix(final String name)
  5. randomUnicodeString(Random r)