Java tutorial
//package com.java2s; import java.util.*; public class Main { public static <V> List<V> shuffleAndSubList(List<V> list, int subSize) { if (list == null || list.size() == 0) { return null; } Collections.shuffle(list); list = list.size() > subSize ? list.subList(0, subSize) : list; return list; } }