我得到了这段代码,但我得到了一个错误incomparable types: java.lang.String and int
,对于这行代码
if ((this.name.String.compareTo(obj.name == 0)) && (this.age = obj.age))
方法是这样的:
public int compareTo(Object o)
{
int result;
AnyClass obj = (AnyClass)o;
if ((this.name.String.compareTo(obj.name == 0)) && (this.age = obj.age))
{
result = 0;
}
else if (this.name.compareTo(obj.name) > 0)
{
result = 1;
}
else
{
result = -1;
}
return result;
}