is to randomly disrupt the original order, and shuffle the same. Such as:
Shuffletest.java import java.util.*; public class Shuffletest {public static void main (string[] args) {list<integer> List = new Arraylist<integer> ;(); for (int i = 0; i < i++) List.add (new Integer (i)); System.out.println ("Before Upset:"); SYSTEM.OUT.PRINTLN (list); for (int i = 0; i < 5; i++) {System.out.println ("the first" + i + "The second Upset:"); Collections.shuffle (list); SYSTEM.OUT.PRINTLN (list); } } }
Output results:
Before the disruption:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
No. 0 Time Upset:
[6, 3, 2, 0, 8, 1, 7, 5, 4, 9]
1th Time Upset:
[6, 2, 3, 0, 8, 5, 7, 4, 9, 1]
2nd time Upset:
[1, 7, 9, 4, 6, 0, 2, 5, 3, 8]
3rd time Upset:
[0, 4, 2, 8, 9, 1, 3, 7, 5, 6]
4th Time Upset:
[8, 1, 3, 0, 7, 9, 4, 2, 5, 6]
Excerpt from: http://topic.csdn.net/u/20080308/17/642f73e3-ff7b-4144-a52b-190a72be1e49.html