@Override public boolean equals(Object o) "Method does not override and superclass method"

时间:2015-06-15 15:20:06

标签: java

Theoretically this is a really simple (dumb) question...

Compiles successfully:

@Override
public int hashCode() {return 0;}

Error: "Method does not override any superclass method"

@Override
public boolean equals(Object obj) {return true;}

It seems to me that if my override of hashCode() compiles the override of equals() should also compile... Obviously I don't understand something relatively fundamental...

What should I look for to resolve this compiler error?

1 个答案:

答案 0 :(得分:0)

我的项目在与展示编译问题的类相同的包中有一个类...这模糊了Java的基础Object类(及其equals()方法)。

以下是更正后的代码:

@Override
public boolean equals(java.lang.Object obj)
{
    return true;
}
相关问题