Java Language The Lambda operator ( -> )


From Java 8 onwards, the Lambda operator ( -> ) is the operator used to introduce a Lambda Expression. There are two common syntaxes, as illustrated by these examples:

Java SE 8
  a -> a + 1              // a lambda that adds one to its argument
  a -> { return a + 1; }  // an equivalent lambda using a block.

A lambda expression defines an anonymous function, or more correctly an instance of an anonymous class that implements a functional interface.

(This example is included here for completeness. Refer to the Lambda Expressions topic for the full treatment.)