Lambda and Stream best practices excerpted from the Modern Java in Action - Lambda, streams, functional and reactive programming.
Java
Lambdas and Streams best-practices
Lambda and Stream best practices extracted from the Modern Java in Action - Lambda, streams, functional and reactive programming and some others. Also, this repo includes some tips when using lambda and streams as a Java developer.
What are lambdas and streams?
List of (non exhautive) intermediate operations of Stream:
Operation
Type
Return Type
Argument of the Operation
Function descriptor
filter
Intermediate
Stream<T>
Predicate<T>
T -> boolean
map
Intermediate
Stream<R>
Function<T, R>
T -> R
limit
Intermediate
Stream<T>
long
distinct
Intermediate
Stream<T>
List of (non exhautive) terminal operations of Stream:
Operation
Type
Return Type
Purpose
forEach
Terminal
void
Consumes each element from a stream and applies a lambda to each of them.
count
Terminal
long
Returns the number of elements in a stream.
collect
Terminal
Stream<T>
Returns a collection from a stream (such as Map, List or event Integer).
Get the name of all dishes with calories greater than 300