作者:施自扬
微信号:sszzyy123aabbcc
参数:list 集合,count 要取的条数
public static List GetRandomThreeInfoList(List list, int count) { List olist = new ArrayList<>(); if (list.size() <= count) { return list; } else { Random random = new Random(); for (int i = 0 ;i<count;i++){ int intRandom = random.nextInt(list.size() - 1); olist.add(list.get(intRandom)); list.remove(list.get(intRandom)); } return olist; } }