0 votes
1 view
in Java by (2.6k points)
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.

1 Answer

0 votes
by (46.1k points)

Try JLS, it will clear your doubts

It is permitted, but discouraged as a matter of style, to redundantly specify the public and/or abstract modifier for a method declared in an interface.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Oct 17 in Java by Shubham (3.9k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...