Error
"This method requires a body instead of a semicolon" while using Default Methods in Java 8.
Error Type
Compile Time ( Java 8 )
Sample Code
DefaultMethodInterface
public interface DefaultMethodInterface {
default public void defaultMethod();
}
Cause
Method declared as default in Interface should have a default method body.
Resolutions
Either provide the method body
public interface DefaultMethodInterface {
default public void defaultMethod(){
System.out.println("Default Method Implementation");
}
}
or
Remove the Default Keyword.
public interface DefaultMethodInterface {
public void defaultMethod();
}
"This method requires a body instead of a semicolon" while using Default Methods in Java 8.
Error Type
Compile Time ( Java 8 )
Sample Code
DefaultMethodInterface
public interface DefaultMethodInterface {
default public void defaultMethod();
}
Cause
Method declared as default in Interface should have a default method body.
Resolutions
Either provide the method body
public interface DefaultMethodInterface {
default public void defaultMethod(){
System.out.println("Default Method Implementation");
}
}
or
Remove the Default Keyword.
public interface DefaultMethodInterface {
public void defaultMethod();
}