记录一下将顺序数组进行乱序排序的代码
List<Object> list = new ArrayList<Object>();
//list初始化,省略
int size = list.size();
for(int i=0;i<size;i++){
Object obj1 = list.get(i);
int index = RandomUtils.nextInt(size);
Object obj2 = list.get(index);
list.set(i,obj2);
list.set(index,obj1);
}
新闻热点
疑难解答