Created
April 17, 2014 15:02
-
-
Save iaveryanov/10990181 to your computer and use it in GitHub Desktop.
lambda pazzle
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
package lambda.puzzle; | |
// source: http://arhipov.blogspot.ru/2014/02/java-8-lambdas-unintentional-puzzle.html | |
public class Forrest { | |
public Runnable wrooom(){ | |
return () -> { System.out.println("Hello, lambda!"); }; | |
} | |
public static void main(String[] args) { | |
Runnable runnable = new Forrest().wrooom(); | |
runnable.run(); // print "Hello, lambda!" | |
Runnable runnable2 = new Forrest()::wrooom; | |
runnable2.run(); // print nothing | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment