Home Programming Learning Java Lambdas

Learning Java Lambdas

By Toby Weston
books-svg-icon Book
eBook $23.99 $15.99
Print $143.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $23.99 $15.99
Print $143.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
About this book
In this short book, we take an in-depth look at lambdas in Java, and their supporting features. The book covers essential topics, such as functional interfaces and type inference, and the key differences between lambdas and closures. You will learn about the background to functional programming and lambdas, before moving on to understanding the basic syntax of lambdas and what differentiates these anonymous functions from standard anonymous classes. Lastly, you'll learn how to invoke lambdas and look at the bytecode generated. After reading this book, you'll understand lambdas in depth, their background, syntax, implementation details, and how and when to use them. You'll also have a clear knowledge of the difference between functions and classes, and why that's relevant to lambdas. This knowledge will enable you to appreciate the improvements to type inference that drive a lot of the new features in modern Java, and will increase your understanding of method references and scoping.
Publication date:
March 2017
Publisher
Packt
Pages
114
ISBN
9781787282087

 

Chapter 1. Introduction

Welcome to Learning Java Lambdas.

Java underwent huge changes in it's version 8 release. A lot was driven by the perception that Java was becoming long in the tooth. To compete with modern, functional programming languages, Java 8 introduced functional programming constructs like lambdas to better support a more functional style.

This book offers a concise explanation of lambdas and various other features required to make them work in Java. As well as offering background, syntax and usage examples of lambdas, the book describes other related features, such as functional interfaces and type inference.

 

The road to modern Java


Java 8 was released on March 18, 2014, two years seven months after the previous release. It was plagued with delays and technical problems but when it finally came, it represented one of the biggest shifts in Java since Java 5.

The headliners were of course lambdas and a retrofit to support functional programming ideas. With languages such as Scala taking center stage and the modern trend towards functional programming, Java had to do something to keep up.

Although Java is not and never will be a pure functional programming language, the changes in Java 8 enabled developers to use functional idioms more easily than in previous versions. With discipline and experience, you can now get a lot of the benefits of functional programming without resorting to third-party libraries.

Modern Java features

To give you an idea of just how big a change Java 8 was, and why it ushered in a new, modern Java, here's a mostly complete list of the new features it introduced:

  • Lambda support.

  • The core APIs were updated to take advantage of lambdas, including the collection APIs and a new functional package to help build functional constructs.

  • Entirely new APIs were developed that use lambdas, things like the stream API which brought functional style processing of data. For example, functions like map and flatMap from the stream API enable a declarative way to process lists and move away from external iteration to internal iteration. This in turn allows the library vendors to worry about the details and optimize processing however they like. For example, Java now comes with a parallel way to process streams without bothering the developer with the details.

  • Minor changes to the core APIs; new helper methods were introduced for strings, collections, comparators, numbers and maths.

  • Some of the additions are changing the way that people code. For example, the Optional class will be familiar to some, and it enables a better way to deal with nulls.

  • There were various concurrency library improvements. Things like an improved concurrent hash map, completable futures, thread safe accumulators, an improved read write lock (called a StampedLock), an implementation of a work stealing thread pool and much more besides.

  • Support for adding static methods to interfaces.

  • Default methods (otherwise known as virtual extension or defender methods).

  • Type inference was improved and new constructs like functional interfaces and method references were introduced to better support lambdas.

  • An improved date and time API was introduced (similar to the popular Joda-time library).

  • The IO and NIO packages received welcome additions to enable working with IO streams using the new streams API.

  • Reflection and annotations were improved.

  • An entirely new JavaScript engine shipped with Java 8. Nashorn replaced Rhino, and was faster and had better support for ECMA-Script.

  • JVM improvements; the integration with JRocket was completed, creating a faster JVM.

  • The JVM dropped the idea of perm gen, instead using native OS memory for class metadata. This is a huge deal and provides better memory utilization.

  • The JRocket integration also brought Mission control (jmc) to the JDK as standard. It compliments JConsole and VisualVM with similar functionality but adds very inexpensive profiling.

  • Other miscellaneous improvements, like improvements to JavaFX, base64 encoding support and more.

About the Author
  • Toby Weston

    Toby Weston - Independent Software DeveloperI specialise in modern software development; functional and object-oriented programming, agile and lean best practice. I wrote the book Essential Acceptance Testing and have written for magazines as well as regularly blogging.I've been part of the software industry for more than fifteen years and love what I do. I love talking and writing about it and sharing my experiences online with Udemy.

    Browse publications by this author
Latest Reviews (1 reviews total)
Good book help solidify the information.
Learning Java Lambdas
Unlock this book and the full library FREE for 7 days
Start now