这是我的代码中的一个例子:
基类:
abstract class AbstractBase implements Comparable<AbstractBase> {
private int a;
private int b;
public int compareTo(AbstractBase other) {
// compare using a and b
}
}
Run Code Online (Sandbox Code Playgroud)
执行:
class Impl extends AbstractBase {
private int c;
public int compareTo(Impl other) {
// compare using a, b and c with c having higher impact than b in AbstractBase
}
Run Code Online (Sandbox Code Playgroud)
FindBugs将此报告为一个问题.但那是为什么呢?怎么会发生什么?
我将如何正确实施解决方案?
sp0*_*00m 13
Impl#compareTo(Impl)AbstractBase#compareTo(AbstractBase)因为他们没有相同的签名,所以不会压倒一切.换句话说,Collections#sort例如在使用时不会调用它.
| 归档时间: |
|
| 查看次数: |
1555 次 |
| 最近记录: |