没废话
/**
* 将list集合内容打散
*
* @param list
* 要打散的list
* @param n
* 要打散前n个
* @return 返回打散后的list
*/
private List createRandomList(List list, int n) {
Map mmap = new HashMap();
List mlistNew = new ArrayList();
while (mmap.size() < n) {
int random = (int) (Math.random() * list.size());
if (!mmap.containsKey(random)) {
mmap.put(random, "");
mlistNew.add(list.get(random));
}
}
return listNew;
}
标签:int,mmap,打乱,random,list,打散,Android,List
来源: https://blog.csdn.net/yuehua_zhang/article/details/90023200