Here you can find the source of randomList(Collection
public static <E> List<E> randomList(Collection<E> collection)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <E> List<E> randomList(Collection<E> collection) { List<E> list = new ArrayList<>(collection); Collections.shuffle(list); return list; }/*from ww w .j a v a 2 s. c om*/ public static <E> List<E> randomList(E[] elements) { return randomList(Arrays.asList(elements)); } public static <E> List<E> asList(E[] array) { if (isEmpty(array)) { return new ArrayList<>(); } return Arrays.asList(array); } private static <E> boolean isEmpty(Collection<E> collection) { return (collection == null || collection.isEmpty()); } private static <E> boolean isEmpty(E[] array) { return (array == null || array.length == 0); } }