java list 随机排序 shuffle()

  |   0浏览

通过 Collections.shuffle(list)来打乱顺序

List<String> list = new ArrayList<String>();        list.add('mjb');        list.add('hh');        list.add('lw');        list.add('pqj');        list.add('hj');        System.out.println('前:');        for(int i=0;i<list.size();i++){            System.out.print(list.get(i)+'    ');        }        System.out.println('www.1b23.com');        System.out.println('后:');        Collections.shuffle(list);        for(int i=0;i<list.size();i++){            System.out.print(list.get(i)+'    ');        }

原文地址:https://blog.51cto.com/14622073/2506883