Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Java Functional Programming

You're reading from   Learning Java Functional Programming Create robust and maintainable Java applications using the functional style of programming

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher
ISBN-13 9781783558483
Length 296 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Richard M. Reese Richard M. Reese
Author Profile Icon Richard M. Reese
Richard M. Reese
Richard M Reese Richard M Reese
Author Profile Icon Richard M Reese
Richard M Reese
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Getting Started with Functional Programming 2. Putting the Function in Functional Programming FREE CHAPTER 3. Function Composition and Fluent Interfaces 4. Streams and the Evaluation of Expressions 5. Recursion Techniques in Java 8 6. Optional and Monads 7. Supporting Design Patterns Using Functional Programming 8. Refactoring, Debugging, and Testing 9. Bringing It All Together Index

Lambda expressions revisited

In this section, we will explore the syntax of lambda expression in more depth. So far, we used them without formally describing them. We will also examine other forms they can take.

As mentioned earlier, a lambda expression is essentially an anonymous function. They can be passed to another function or method, returned from a function or a method, and assigned to variables.

A lambda expression consists of an optional parameter list, followed by the lambda operator, and then a body. The lambda operator is a dash followed by the greater than symbol. The body of a lambda expression may be one or more statements and may optionally return a value.

Let's examine several variations of a simple lambda expression. A single value is passed to the function. This value is incremented and then returned. Several equivalent variations of this function are illustrated in the following table:

Variation

Comment

x -> x + 1

The simplest form of the function

(x) -&gt...
You have been reading a chapter from
Learning Java Functional Programming
Published in: Oct 2015
Publisher:
ISBN-13: 9781783558483
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime