import java.util.Random;
public class test2 {
?public static void main(String args[]) {
??RandomTest();
?}
?
?// 數組自由排列
?public static void RandomTest(){
??Random ran = new Random();
??int a[] = { 1, 2, 3, 4, 5 ,6,7,8,9};
??int b[] = new int[a.length];
??int w = a.length;
??int x = 0;
??int y;
??
??for (int i = 0; i < a.length; i++) {??
???y = 0;
???x = Math.abs(ran.nextInt()) % w;
???// 把隨機選中的數,提出來,然后省下數重新排列數組
???for (int j = 0; j < w; j++) {
????if (x == j) {
?????b[i] = a[x];
?????continue;15:59:4715:59:582006年11月29日
????}
????a[y] = a[j];
????y++;
???}
???w--;
???System.out.print("~" + b[i] + "~");
??}
?}
}