Skip to content

Instantly share code, notes, and snippets.

@LazaroIbanez
Created September 3, 2017 16:58
Show Gist options
  • Save LazaroIbanez/a260bbda387bf7d17308477bb4f2cc78 to your computer and use it in GitHub Desktop.
Save LazaroIbanez/a260bbda387bf7d17308477bb4f2cc78 to your computer and use it in GitHub Desktop.
The default keyword
public class D implements Interface2 {
public static void main (String… args) {
Interface1 acct = new D();
System.out.println(acct.getId());
}
public String getId() {
return “1111”;
}
}
interface Interface1 {
public default String getId() {
return “0000”;
}
}
interface Interface2 extends Interface1 {
public String getId();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment