-
Notifications
You must be signed in to change notification settings - Fork 372
Open
Description
Rule 3: Otherwise, the class has to call the desired implementation unambiguously
Running with
openjdk version "1.8.0_144"
OpenJDK Runtime Environment (Zulu 8.23.0.3-macosx) (build 1.8.0_144-b01)
OpenJDK 64-Bit Server VM (Zulu 8.23.0.3-macosx) (build 25.144-b01, mixed mode)
will got error:
Error:(7, 8) java: class com.example.Test inherits unrelated defaults for test() from types com.example.TestAInterface and com.example.TestBInterface
public interface TestAInterface {
default String test() {
System.out.println("in a");
return "a";
}
}
public interface TestBInterface {
default String test() {
System.out.println("in b");
return "b";
}
}
public class Test implements TestAInterface, TestBInterface {
}
class App {
public static void main(String[] args) {
Test a = new Test();
a.test();
}
}
Metadata
Metadata
Assignees
Labels
No labels