package com.ozs.common.utils;


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class RandomUtil {
    public static List getRandomList(List list, int randomSeriesLength){
        if(randomSeriesLength >  list.size()){
            randomSeriesLength = list.size();
        }
        Collections.shuffle(list);
        List randomSeries = list.subList(0, randomSeriesLength);
        return randomSeries;
    }
    public static void main(String args[]){
        List<Object> list = new ArrayList<>();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");
        list.add("5");
        list = getRandomList(list,8);
        for(Object o: list){
            System.out.println(o);
        }
    }
}
