Skip to content

Instantly share code, notes, and snippets.

@iaveryanov
Created April 17, 2014 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iaveryanov/10990181 to your computer and use it in GitHub Desktop.
Save iaveryanov/10990181 to your computer and use it in GitHub Desktop.
lambda pazzle
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