Skip to content

Instantly share code, notes, and snippets.

@philipschwarz
Last active August 29, 2015 14:13
Show Gist options
  • Save philipschwarz/0d3497b7484e89984e9c to your computer and use it in GitHub Desktop.
Save philipschwarz/0d3497b7484e89984e9c to your computer and use it in GitHub Desktop.
tasting the lambda syntactic sugar that the Java 8 Compiler lets you write in place of an instance of a required functional interface
IntStream.of(1, 2, 3).forEach( new IntConsumer() { public void accept(int value) { System.out.println(value); } } );
IntStream.of(1, 2, 3).forEach( new IntConsumer() { public void accept(int n) { System.out.println(n); } } );
IntStream.of(1, 2, 3).forEach( (int n) -> { System.out.println(n); } );
IntStream.of(1, 2, 3).forEach( (int n) -> System.out.println(n) );
IntStream.of(1, 2, 3).forEach( n -> System.out.println(n) );
IntStream.of(1, 2, 3).forEach( System.out::println );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment