Capturing lambdas

This lesson explains what capturing lambdas are and discusses a few of the caveats of using them.

A lambda expression is said to be capturing if it either accesses instance variables of it’s enclosing class or local variables (final or effectively final) from it’s enclosing scope.

A lambda expression can capture the three types of variables given below:

  • Static variables
  • Instance variables
  • Local variables

If a lambda expression captures ...