1 //效率取随机不重复数 2 public int[] takeRandom(int num) { 3 Random rd = new Random(); 4 int[] rds = new int[num];//随机数数组 5 List list = new ArrayList();//存放有序数字集合 6 int index = 0;//随机索引 7 for (int i = 0; i < num; i++) { 8 list.add(i); 9 } 10 for (int i = 0; i < num; i++) { 11 index = rd.nextInt(num - i); 12 rds[i] = (Integer) list.get(index); 13 list.remove(index); 14 } 15 return rds; 16 }