Should methods in a Java interface be declared with or without the public access modifier?
Technically it doesn't matter, of course. A class method that implements an interface is always public. But what is a better convention?
Java itself is not consistent in this. See for instance Collection vs. Comparable, or Future vs. ScriptEngine.
The JLS makes this clear:
It is permitted, but discouraged as a matter of style, to redundantly specify the
publicand/orabstractmodifier for a method declared in an interface.
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