package com.it02;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
public class Demo {
public static void main(String[] args) {
//1.创建集合对象
// Set<Integer> set = new HashSet<Integer>();
Set<Integer> set = new TreeSet<Integer>();
//2.创建随机对象
Random r = new Random();
//3.判断集合长度是不是小于10
while (set.size()<10){
//产生一个随机数保存到集合
int number = r.nextInt(20)+1;
set.add(number);
}
//4.遍历集合
for (Integer i: set) {
System.out.println(i);
}
}
}