java--HashSet

public class qiantao_1 {
//产生10个1到20之间的随机数
public static void main(String[] args) {
// TODO Auto-generated method stub
//extracted();
//extracted_2();
Random r = new Random();
HashSet hs= new HashSet<>();
while(hs.size()< 10) {
hs.add(r.nextInt(20+1));
}
for(Integer integer:hs) {
System.out.println(integer);
}

}
posted @ 2020-06-01 16:09  雨曼晴川  阅读(105)  评论(0编辑  收藏  举报