Created
June 14, 2013 16:58
-
-
Save buzztaiki/5783537 to your computer and use it in GitHub Desktop.
default methodで実験
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface I1 { | |
| default String id() { | |
| return "I1"; | |
| } | |
| default String id1() { | |
| return id(); | |
| } | |
| } | |
| interface I2 { | |
| default String id() { | |
| return "I2"; | |
| } | |
| default String id2() { | |
| return id(); | |
| } | |
| } | |
| class C implements I1, I2 { | |
| public String id() { | |
| return I1.super.id(); | |
| } | |
| } | |
| public class A { | |
| public static void main(String[] args) throws Exception { | |
| C c = new C(); | |
| System.out.println(c.id()); | |
| System.out.println(((I1)c).id()); | |
| System.out.println(((I1)c).id1()); | |
| System.out.println(((I2)c).id()); | |
| System.out.println(((I2)c).id2()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment