根据指定的List和取出数得到子List public List getSubStringByRadom(List list, int count){ List backList = null; backList = new ArrayList (); Random random = new Random(); int backSum = 0; if (list.size() = count) { backSum = count
public ListgetSubStringByRadom(List list, int count){ List backList = null; backList = new ArrayList (); Random random = new Random(); int backSum = 0; if (list.size() >= count) { backSum = count; }else { backSum = list.size(); } for (int i = 0; i < backSum; i++) { // 随机数的范围为0-list.size()-1 int target = random.nextInt(list.size()); backList.add(list.get(target)); list.remove(target); } return backList; }