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
Hands-On Design Patterns with Java

You're reading from   Hands-On Design Patterns with Java Learn design patterns that enable the building of large-scale software architectures

Arrow left icon
Product type Paperback
Published in Apr 2019
Publisher Packt
ISBN-13 9781789809770
Length 360 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Dr. Edward Lavieri Jr. Dr. Edward Lavieri Jr.
Author Profile Icon Dr. Edward Lavieri Jr.
Dr. Edward Lavieri Jr.
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Section 1: Introducing Design Patterns
2. Unified Modeling Language Primer FREE CHAPTER 3. Object-Oriented Design Patterns 4. Section 2: Original Design Patterns
5. Behavioral Design Patterns 6. Creational Design Patterns 7. Structural Design Patterns 8. Section 3: New Design Patterns
9. Architectural Patterns - Part I 10. Architectural Patterns - Part II 11. Functional Design Patterns 12. Reactive Design Patterns 13. Assessments 14. Other Books You May Enjoy

Understanding the lambda design pattern

Lambda functionality was introduced in Java 8 and has forever changed the landscape of programming in Java. The lambda functional design pattern uses lambda functions, also referred to as anonymous functions. These functions are passed as arguments to other functions.

Lambda functions have three parts:

  • A single parameter: (argument)
  • The arrow operator: ->
  • The body: (body)

As with anything else in Java, there are a bunch of rules associated with even this seemingly simple syntax:

  • If the parameter on the left has its type explicitly stated, it and the parameter must be encased in parenthesis, for example, (String a)
  • The body can only call a single method
  • The body must return a result
  • For bodies with only one parameter, you do not need braces or a semicolon
  • For bodies with more than one parameter, you do need braces and a semicolon
  • You...
lock icon The rest of the chapter is locked
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 £16.99/month. Cancel anytime