这里是我的compareTo方法,但即时通讯仍然收到“缺少返回语句”警告。 任何人都可以告诉我我的代码有什么问题吗?如何覆盖compareTo方法
public int compareTo(Flows other) {
if(this.srcAddr.equals(other.srcAddr)){
if(this.dstAddr.equals(other.dstAddr)){
if(this.srcPort.equals(other.srcPort)){
if(this.dstPort.equals(other.dstPort)){
if(this.protocol.equals(other.protocol)){
return 0;
}
}
}
}
}
}
首先,为什么这个社区wiki?其次,如果'this.srcAddr.equals(other.srcAddr)'为false,请考虑返回的内容;]。 – pablochan 2010-08-13 09:30:06
相信我你不能正确实现这个,直到你真的知道你想如何订购你的“MyKey”对象:)首先决定你的业务逻辑是什么。 – Gopi 2010-08-13 09:35:34
@Gopi,你的意思是,Flows对象? – aioobe 2010-08-13 09:39:51