Let’s break down how to consume local variable with lambda functions in java

The following scenarios will be covered,

  1. Lambda consumes local variable initialized in a method
  2. Local variable initialized in the Lambda function
  3. Manipulating local variable inside the lambda function
  4. Manipulating local variable outside the lambda function
  5. Lambda functions consuming local reference variable
  6. Declaring variables inside the lambda function
  7. Using This in Lambda
  8. Naming Convention in Lambda

Lambda and Local Variables

Let’s take a class (Doge) that consumes a Functional Interface (PrintCoin) which prints the number of coins.

The Functional Interface…


Let’s break down how to consume instance variable with lambda functions in java

The following scenarios will be covered,

  1. Lambda consumes an instance variable initialized in a method
  2. Lambda consumes an instance variable initialized in the Lambda function
  3. Lambda functions consuming reference variable

Instance Variable and Lambda Function

Let’s take a class (Doge) that consumes a Functional Interface (PrintCoin) which prints the number of coins.

The Functional Interface look like this, which takes a single abstract method print()

@FunctionalInterface
interface PrintCoin{
void print();
}

The Class Doge looks like this, we define the…


Let’s learn about how to play around with static variables in lambdas.

The following scenarios will be covered

  1. Lambda consumes a static variable initialized in a static method
  2. Lambda consumes a static variable initialized in lambda
  3. Lambda functions with parameters and Static Variable
  4. Static Reference Variable with Lambdas

Static Variable With Lambdas

Let’s take a class (Doge) that consumes a Functional Interface (PrintCoin) which prints the number of coins.

The Functional Interface look like this, which takes a single abstract method print()

@FunctionalInterface
interface PrintCoin{
void print();
}

The Class Doge looks…

Noob Codes

Come explore the world of programming with me!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store