I have stumbled upon a strange issue working with default methods.
Consider this situation:
interface A {
int method();
}
interface B {
default int method() {
return 1;
}
}
class C implements A, B {
void anotherMethod() { }
}
I would expect class C
to be fine as-is: it should implement method
, because that's the contract of both A
and B
, and it actually does, because B
provides a default implementation.
However, the compiler does not agree with me, saying:
C is not abstract and does not override abstract method method()
I can totally see the issue in other similar cases, such as this one, but I can't figure out what's wrong with this code.