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

Debugging lambda expressions


Both NetBeans and Eclipse support debugging lambda expressions. While it is always possible to create multiline lambda expressions and use print statements to display the values of variables, it is better to use a debugger when possible. Not only do we have to add additional statements which would have to be removed in the production version of the application, but debuggers also provide additional information about the state of the program and frequently allow some variables to be modified while the debugger is executing.

We will demonstrate how to debug a lambda expression that takes a string and returns the string concatenated with its lowercase equivalent. This operation is shown here:

    List<String> list = Arrays.asList("Huey", "Dewey", "Louie");
    list.stream()
            .map(s -> s + "-" + s.toLowerCase())
            .forEach(s -> System.out.println(s));

When this code executes, you will get the following output:

Huey-huey
Dewey-dewey
Louie...
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 $19.99/month. Cancel anytime