package MONA.demo04_set;
import java.util.HashSet;
import java.util.Random;
/**
* 获取10个不重复的1至20之间的随机数
*/
public class Demo05 {
public static void main(String[] args) {
HashSet<Integer> hashSet = new HashSet<>();
Random r = new Random();
while (hashSet.size()<10){
int i = r.nextInt(20) + 1;
hashSet.add(i);
}
System.out.println(hashSet);
}
}