hashset和treeset
Set<Integer> set=new TreeSet<>();//HashSet不会排序,treeset会排序
while (set.size()<10){
Random r=new Random();
int i= r.nextInt(20)+1;
set.add(i);}
for (Integer I: set) {
System.out.print(","+I);
}
hashset和treeset
Set<Integer> set=new TreeSet<>();//HashSet不会排序,treeset会排序
while (set.size()<10){
Random r=new Random();
int i= r.nextInt(20)+1;
set.add(i);}
for (Integer I: set) {
System.out.print(","+I);
}