Consider an example (which compiles in java)
public abstract interface Interface {
public void interfacing();
public abstract boolean interfacing(boolean really);
}
Why is it necessary for an interface to be "declared" abstract? Is there other rules that applies with an abstract interface?
Finally: If abstract
is obsolete, why is it included in Java? Is there a history for abstract interface?
Best Answer
It's not.
Interfaces and their methods are implicitly
abstract
and adding that modifier makes no difference.No, same rules apply. The method must be implemented by any (concrete) implementing class.
Interesting question. I dug up the first edition of JLS, and even there it says "This modifier is obsolete and should not be used in new Java programs".
Okay, digging even further... After hitting numerous broken links, I managed to find a copy of the original Oak 0.2 Specification (or "manual"). Quite interesting read I must say, and only 38 pages in total! :-)
Under Section 5, Interfaces, it provides the following example:
And in the margin it says
Assuming
=0
got replaced by theabstract
keyword, I suspect thatabstract
was at some point mandatory for interface methods!Related article: Java: Abstract interfaces and abstract interface methods