ERROR - Illegal combination of modifiers for the interface method defaultMethod; only one of abstract, default, or static permitted

Error

"Illegal combination of modifiers for the interface method defaultMethod; only one of abstract, default, or static permitted" while using Default Methods in Java 8.

Error Type

Compile Time ( Java 8 )

Sample Code

public interface DefaultMethodInterface {
    default static public void defaultMethod(){
        System.out.println("DefaultMethodInterface");
    }
}
   
Cause

Static methods cannot be declared default.  

Resolutions

Either make the method Default and remove the keyword static

public interface DefaultMethodInterface {
    default public void defaultMethod(){
        System.out.println("DefaultMethodInterface");
    }
}

or 

Make the method static and remove the keyword default.


public interface DefaultMethodInterface {
    default public void defaultMethod(){
        System.out.println("DefaultMethodInterface");
    }
}