Created
June 15, 2016 03:49
-
-
Save itang/61e1b3bc740093d6db516b39fa7e0910 to your computer and use it in GitHub Desktop.
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 Nameable { | |
| String getName(); | |
| } | |
| public class Test { | |
| public static void main(String[] args) { | |
| Nameable nameable1 = "String"::toString; | |
| hello(nameable1); | |
| hello("String"::toString); | |
| Nameable nameable2 = () -> "yourname"; | |
| hello(nameable2); | |
| hello(() -> "yoruname2"); | |
| // hello(() -> 111 ); // compile error | |
| } | |
| public static void hello(Nameable n) { | |
| System.out.println("hello " + n.getName()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment