集合中随机取一个值

List<实体> sirList = testDao.querysirList(test);//根据test查询
Setup rir = new Setup();
int size = sirList.size();
for(int i = 0;i<size;i++){
Random random = new Random();
int n = random.nextInt(sirList.size());
rir = sirList.get(n);
String distribution = rir.getDistributionRatio();
if("0".equals(distribution)) {
break;
}else {
}
sirList.remove(n);//移除不符合的
}

posted on 2021-10-25 14:51  多言  阅读(95)  评论(0编辑  收藏  举报

导航