标签:obj eset oid ring 重写 custom font int string
package priv.sex.set;
import java.util.Comparator;
import java.util.TreeSet;
class Mycompore implements Comparator {
public int compare(Object object1,Object object2) {
String s1=(String)object1;
String s2=(String)object2;
return s1.length()-s2.length();
}
}
public class CustomTreeSetDemo implements Tool{
public static void main(String[] args) {
TreeSet treeSet =new TreeSet(new Mycompore());
treeSet.add("qwer");
treeSet.add("asdfg");
treeSet.add("as");
treeSet.add("2");
Tool.IteratorPrint(treeSet);
}
}
标签:obj eset oid ring 重写 custom font int string
原文地址:https://www.cnblogs.com/this-is-me55/p/11649831.html