I understand that Interface methods are implicitly public. Java Docs Tutorial says
All
abstract,default, and <
In Java 8, we have as per Java Docs Tutorials,
All abstract, default, and static methods in an interface are implicitly public, so you can omit the public modifier.
Thus the only allowed access modifier in an Interface as of Java 8 is public. (Java 9 introduces private interface methods)
public interface TestInterface {
int print();//compiles and no IDE warning
public int print1();//public redundant
}
abstract - methods in an interface that are not declared as default or static are implicitly abstract, so the abstract modifier is optional. But the method implementation must not be provided in such case.
static- static needs to be explicitly specified and implementation provided.
final - A final methods can't be overridden and is not allowed for an interface method.
default - method can be explicitly declared default if the default implementation is provided.
All fields in Interfaces are public, static and final.