If we are not adding any access specifier to method by default it is of default type.
but we are adding default
keyword then it is giving me error, like we can have default method in interface only. I am aware about the default method in functional interface but strange why it is showing error in eclipse.
public class Test
{
default void test() { //Default methods are allowed only in interfaces.
}
}
this one is working fine
public class Test
{
void test()
{
}
}
any reason for it?