Skip to content

Instantly share code, notes, and snippets.

@bloodredsun
Last active August 29, 2015 14:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bloodredsun/c206ac7b94bcce643ac3 to your computer and use it in GitHub Desktop.
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