Stimulated by the question Interface vs Abstract Classes and the accepted answer, I would like to have a more detailed and clarified answer. In particular I cannot understand the statement “a field in an interface is implicitly static and final”. Does it mean that a class A implementing an interface containing method foo() can invoke the method as A.foo()?
What concerning final: As long as interfaces contain only methods, given an abstract class A which implements an interface with a method foo() and an ordinary class B which extends the abstract class A, cannot the class B override the foo method? As far as I am concerned, final methods are impossible to be overridden. What is true finally?
In an interface writing
are all the same.
Fields and method are both members, but methods and fields are not the same thing.
Methods in an interface cannot be
staticorfinal, but are implicitly public and abstractare all the same for an interface.
final instances methods cannot be overridden and final static methods cannot be hidden.
Similarly nested interfaces, classes and annotations are public and static. Nested interfaces and annotations are also implicitly abstract.