public int compareTo(Object o) {
// TODO Auto-generated method stub
Apple apple=(Apple)o;
return this.water=apple.water; //treeSet.add(apple1);treeSet.add(apple2);add的时候,调用compareTo方//法,apple2的water被赋值为apple1的water
}
//compareTo方法应该为
public int compareTo(Object o) {
// TODO Auto-generated method stub
Apple apple = (Apple) o;
return this.water - apple.water;
}
------解决方案-------------------- 比较是相减的