Java Programming/Lambda expressions

Introduction
Lambda expressions were introduced in Java 8 as a concise way to describe a piece of functionality as a first class member of the language. While the principle is similar to the use of anonymous inner classes to satisfy interfaces, lambda expressions make the code much more legible.

I.e., instead of

we can say simply:

Syntax
A lambda expression consists of two parts separated by the  characters, referred to as an "arrow": Parameters -> Body

Parameters
The Parameters define the inputs to the expression. Generally, the Parameters are a comma-separated list of types and identifiers surrounded by parentheses: ( Type1 identifier1, Type2 identifier2 ) -> Body However, the types are often inferable from the context and can be omitted: ( identifier1, identifier2 ) -> Body And also, if there is exactly one input and its type is inferable, the parentheses can be omitted: identifier1 -> Body

Body
The body of the lambda expression describes what should be done with those inputs (if any). In general, the body is a block like any other: Parameters -> { statements; ...   return statement; } The return statement can be omitted for expressions that simply operate on the inputs. Parameters -> { statements; ... } If the body consists only of a single statement, the braces and terminal semi-colon can be omitted: Parameters -> statement If the expression consists of a single return statement, the braces, return keyword, and terminal semi-colon can all be omitted: Parameters -> result

Terminology
The java.util.function namespace contains many structures out-of-the-box, introducing some standard terminology falling under 3 broad types: Function and Consumer also have "Bi" variants accepting two inputs:
 * 1) "Functions": real functions in the mathematical sense, taking exactly one input and providing exactly one output;
 * 2) "Consumers": entities that accept inputs but do not provide any output (in the conventional sense); and
 * 3) "Suppliers": entities that provide a value every time it is invoked without requiring any input.