TreeSet的有序性及唯一性


public class Demo10 {
public static void main(String[] args){
TreeSet<Integer> set = new TreeSet<>();
set.add(15);
set.add(15);
set.add(13);
set.add(18);
set.add(19);
set.add(19);
set.add(20);
set.add(21);

for (int x:set){
System.out.println(x);
}
}
}

输出结果:

13
15
18
19
20
21

猜你喜欢

转载自www.cnblogs.com/WTBK/p/9424592.html