import java.util.*;
import static java.lang.Math.min;
public class ListSample {
public static <T> List<T> Sample(List<T> source, int sampleSize){
List<T> copy = new ArrayList<T>(source);
Collections.shuffle(copy);
return copy.subList(0, min(copy.size(), sampleSize));
}
public static void main(String[] args) {
List<Integer> nekaLista = new ArrayList<Integer>();
for(int i=0; i<20;i++)
nekaLista.add(i);
System.out.println(nekaLista);
System.out.println(Sample(nekaLista, 5));
System.out.println(nekaLista);
}
}