java 8 notes

Summary of Different Syntaxes to Write Lambda Expressions in Java 8

Java 8 allows you to write lambda expressions in few varying syntaxes. Let us quickly see those here.

 

With no arguments

Runnable r = () -> System.out.println(“H”);

 

Only one argument: with or without parenthesis

ActionListener al1 = (event) -> System.out.println(“Button clicked”);

ActionListener al2 = event -> System.out.println(“Button clicked”);

 

Introdution to Functional Programming and Lambda Expressions

In functional programming, we think in terms of functions. While Object Oriented programming abstract over data, functional programming abstract over behavior. Instead of data, stateless functions are be passed across the code. 

Lambda expressions are Java's way of doing functional programming. Lambda expressions in computer science are anonymous functions: a function (or a subroutine) defined, and possibly called, without being bound to an identifier.

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!