标签:compare 抽象 定义类 new t code java hashset system 定义
底层是用HashSet来实现的,也能够实现排序 Set<Integer> set =new TreeSet<>();
set.add(200);
set.add(600);
set.add(100);
for(Integer i :set)
{
System.out.println(i); //递增排序
}
要实现自定义类排序,需要实现comparable<>接口和compareTo(...)抽象方法
标签:compare 抽象 定义类 new t code java hashset system 定义
原文地址:https://blog.51cto.com/14437184/2422110