default method in java 8 example
Example: default method in java
public interface SomeInterface(){
default void test(){
//this will be done when the method is called by default
}
}
public class SomeInterfaceImpl implements SomeInterface{
//has test method from SomeInterface, can be overwritten
}
public class SomeClass{
public void test(){
//do something else
}
}
public class SomeOtherClass extends SomeClass implements SomeInterface{
//uses the test method from SomeClass
}