Created
July 26, 2013 02:20
-
-
Save watermint/6085556 to your computer and use it in GitHub Desktop.
enumにデフォルト実装をもたせられるか
This file contains 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 Animal { | |
default void say() { | |
System.out.println("I'm Animal"); | |
} | |
} | |
enum Bird implements Animal { | |
Sparrow, | |
Pigeon | |
} | |
public class A { | |
public static void main(String... args) { | |
Bird.Sparrow.say(); | |
} | |
} |
This file contains 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
% /usr/libexec/java_home -v 1.8 -exec javac A.java | |
% /usr/libexec/java_home -v 1.8 -exec java A | |
I'm Animal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment