Java 8 : Lambda in Functional Interfaces

Lambda expressions in Java is usual written using syntax (argument) -> (body).

Functional Interface is an interface with just one abstract method declared in it.

Example:

  • ActionListener Interface
  • Runnable Interface

We generally use Anonymous inner classes to instantiate objects of functional interface but with the help of Lambda expressions, this can be simplified.

screen-shot-2016-12-15-at-6-13-30-pm

Output:

screen-shot-2016-12-15-at-6-16-47-pm

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s