Showing posts with label Lambdas. Show all posts
Showing posts with label Lambdas. Show all posts

Thursday, 4 February 2016

Java 8 - Syntax to represent Lambdas

Below is the syntax for representing a Lambda expression :
parameter(s) −> expression(s)
where
  • parameter(s) has the following rules:
  1. Optional type declaration
  2. Optional comma, only for more than one parameter
  3. Optional brackets, only for more than one parameter
  • expression(s) has the following rules:
  1. Optional curly braces
  2. Optional return keyword
As quoted from the Oracle site:

"Note that a lambda expression looks a lot like a method declaration; you can consider lambda expressions as anonymous methods—methods without a name."