0
method type in Interface Class in java
Hi all i got error for method type in "default" , "private" and "protected" for this method is only type , public?? my Inerface: interface Parent { final int i = 0; default void showmsg(); }
2 Answers
+ 3
Interface is reference type like classes. It's only contains Constants, method signature, defult method.
Interface variable and method are public static final by default.
So other modifiers are not allowed, that's why you get those error.
Interface method are abstract , but from java 8 interface method are allowed not to be abstract. (default methods)
If you having trouble with defult methods than probably you are using older java version.
+ 1
ok
my java version:
java version "1.8.0_112"
my error :
missing method body or declare abstract!!