Issue
package p;
public interface t1 {
int t = 6;
default void method_default(){
System.out.println("default method");
}
}
Why am I getting these errors in my eclipse IDE after writing the above code?
- Abstract methods do not specify a body
- Illegal modifier for the interface method method_default; only public & abstract are permitted
- Syntax error on token "default", delete this token
I am using JDK 14.0.1 and JRE 1.8.0_251.
Solution
There is no syntax issue as long as the compiler version is 1.8 or above.
First check Installed JREs
and then check the JDK Compliance in your eclipse and apply the required version if any of them is set at a lower version.
Answered By - Arvind Kumar Avinash
Answer Checked By - Marilyn (JavaFixing Volunteer)