Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
package com.brs;
// THIS DOES NOT COMPILE!!!
public class JavaDefaultMethodMultiInheritanceExample {
public static void main(String[] args) {
MyOtherJavaExample myJavaExample = new MyOtherJavaExample();
myJavaExample.writeOut();
}
}
class MyOtherJavaExample implements SubInterfaceOne, SubInterfaceTwo {
}
interface BaseInterface {
void writeOut();
}
interface SubInterfaceOne extends BaseInterface {
default void writeOut() {
System.out.println("In SubInterfaceOne");
}
}
interface SubInterfaceTwo extends BaseInterface {
default void writeOut() {
System.out.println("In SubInterfaceTwo");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment