treeSet必须加的对象实现Comparable接口
class UserNumData implements Comparable
并实现它的public int compareTo(Object o) {
return 0;
}
方法

解决方案 »

  1.   

    将类UserNumData 实现 Comparable接口就行
      

  2.   

    This class guarantees that the sorted set will be in ascending element order, sorted according to the natural order  of the elements (see Comparable), or by the comparator provided at set creation time, depending on which constructor is used.
      

  3.   


    set = new TreeSet(new java.util.Comparator(){
    public int compare(Object o1, Object o2){
    UserNumData u1 = (UserNumData)o1;
    UserNumData u2 = (UserNumData)o2;
    return u1.getTelNum()+u1.getName().hashCode() - (u2.getTelNum()+u2.getName().hashCode());
    }
    });