Created
November 16, 2018 13:30
-
-
Save SungjinYoo/5ec8edd892cae8ec1c7103cd9b529978 to your computer and use it in GitHub Desktop.
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
@FunctionalInterface | |
interface Printer { | |
void print(String value); | |
} | |
class TextPrinter implements Printer { | |
void print(String value) { | |
System.out.println(value); | |
} | |
} | |
Printer printer = new TextPrinter(); | |
printer.print("Hi"); // prints out "Hi" | |
printer = printer::print; | |
printer.print("Hi"); // also prints out "Hi" | |
Printer printer = (value) -> { | |
System.out.println(value); | |
} | |
printer.print("Hi"); // prints out "Hi" | |
printer = System.out::println; | |
printer.print("Hi"); // also prints out "Hi" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment