标签:ring integer code lis style shu import div main
就是随机打乱原来的顺序,和洗牌一样。如:
1 // ShuffleTest.java
2
3 import java.util.*;
4
5 public class ShuffleTest {
6 public static void main(String[] args) {
7 List<Integer> list = new ArrayList<Integer>();
8 for (int i = 0; i < 10; i++)
9 list.add(new Integer(i));
10 System.out.println("打乱前:");
11 System.out.println(list);
12
13 for (int i = 0; i < 5; i++) {
14 System.out.println("第" + i + "次打乱:");
15 Collections.shuffle(list);
16 System.out.println(list);
17 }
18 }
19 }
标签:ring integer code lis style shu import div main
原文地址:http://www.cnblogs.com/javatrain/p/6551222.html