Why can't we create an interface with default static method?
public interface StaticTest {
default static void display() {
System.out.println("Display here");
}
}
Why can't we create an interface with default static method?
public interface StaticTest {
default static void display() {
System.out.println("Display here");
}
}
Static methods cannot be overridden or inherited in any meaningful sense, and default methods are there to be overridden or inherited. Just like other non-static interface methods, but default specifically implies that inheritance is meaningful to this method, which is incompatible with static.