随机数组一定是随机的,但可不可以不重复呢?当然可以!
研究了好久!
boolean[] bool = new boolean[fruits.length];
for(int i=0;i<fruits.length;i++) {
int index;
do {
Random random = new Random();
index = random.nextInt(fruits.length);
} while (bool[index]);
bool[index] = true;
fruitList.add(fruits[index]);