// 可以利用Set集合值不重复的特性
Set<Integer> randomList = new LinkedHashSet<>();
ThreadLocalRandom threadLocalRandom = ThreadLocalRandom.current();
int index = 0;
while (randomList.size() < 10) {
randomList.add(threadLocalRandom.nextInt(1,21));
index ++;
}
System.out.println("随机次数为: "+ index);
randomList.forEach(System.out::println);