Something I've seen a lot but never thought to question it... In a Java Interface, what is the difference between:
public void myMethod();
and
public abstract void myMethod();
I understand the purpose of the abstract keyword in a Java class, but what purpose does it serve (if any) in an interface?
Both declarations are completely the same, all interface methods do not have implementation (are abstract) hence the abstract
keyword is redundant. In my opinion writing abstract
in this case increases verbosity of code.
All method declarations are both public
and abstract
in an interface. No point specifying it at all.
Only void myMethod();
is really needed here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With