Reputation: 29673
I'm using JDK 1.5, here is my class:
public final class Account implements ICAccount
{
//...
@Override
public ObjectID getId()
{
return new ObjectID(id);
}
//...
}
Account
overrides method getId()
from ICAccount
But compilation fails.
Account.java method does not override a method from its superclass
If i'm using JDK 1.6 the compilation succeeds.
In documentation to @Override annotation I see
Since:
1.5
What is the problem?
Upvotes: 2
Views: 2383
Reputation: 11607
In Java 1.5 the @Override
annotation is not allowed for methods that implement an interface method, only for methods that in fact override methods from a superclass. This changed in Java 1.6.
Upvotes: 2
Reputation: 2113
The Override annotation is only used when overriding methods from classes in java 1.5. It also works for implementation of interface methods from Java 1.6.
Upvotes: 6