Java 8 Interface Default and Static Method
Before Java 8, you can only declare public abstract methods in an Interface. With Java 8, Interface can have static method and default method.
Interface with Static Method and Default Method
MyInterface interface has a default method foo()
and static method bar()
1 | public interface MyInterface { |
Implementation
1 | public class MyInterfaceImpl implements MyInterface { |
static method and default method demo
1 | public static void main(String[] args) { |