Java 8 Static Interface methods with code samples
Just like default methods , Java 8 also supports static methods in interfaces. In this blog post, I will be explaining Java 8 static interface methods in detail. I will be covering what static methods are, how they work and why they were added. Edit What are static interface methods? Static interface methods are methods with the static keyword are with a method body. How do static interface methods work? Consider the following code snippet: </pre>public interface MyInterface {static public void staticMethod(){System.out.println("In staticMethod of interface");}}<pre> So in the code above, the staticMethod is a static interface method. So we have defined a method with a method body within the interface. It has the static keyword specified. Prior to Java 8, the above code would have caused an error due to two reasons: There is a method with a method body within the interface There is a static method with in the interface How are they similar to default method...