Java 8 New Features: A Practical Heads-Up Guide

Richard Reese

Buy Now UK     Buy Now USA     Buy Now PDF

Are you are worried you are missing out on the latest version of Java? When you hear a term such as lambda expressions - do you wonder what you are neglecting? If so, Java 8 New Features will squash your concerns and deliver a quick and easy-to-understand guide to what's new in Java 8.

The latest version of Java offers numerous improvements and new features to better utilize Java. Streams, for example, supports a fluent approach to problem solving and lets the developer take advantage of concurrency with minimal effort, whilst Lambda Expressions offer new ways of expressing a solution that brings efficiency and succinct programming.

Java 8 Book Cover
 Amazon review

About This Java 8 book

Java 8 New Features is a concise new book filled with code examples and best practice.

In the book, you will:

> Learn how interface enhancements - such as default methods - affect new additions to Java 8 and their impact on multiple inheritance between interfaces

> Use lambda expressions to simplify solutions to development problems

> Discover how the new Stream interface supports query type problems

> Explore the new support for concurrent processing including that supported by Streams

> Find out why the new date and time enhancements make working with time so much easier than it used to be

> Includes information on the Nashorn JavaScript Engine, File IO Enhancements, and Project Jigsaw  


Who this book is for

This book is intended for Java developers who are familiar with Java 7 (and earlier) and who want to get up-to-speed, quickly, on the new features found in Java 8.


About The Author

Richard Reese is an acclaimed author who has written several Java and C books, bringing a focused and easy-to-follow approach to learning. He currently teaches at Tarleton State University.


Buy Now UK     Buy Now USA     Buy Now PDF

Published May 15th, 2014 | 198 pages (paperback) $19.99 | eBook $9.99 | ISBN: 978-0992910570

Table of Contents

Chapter 1 - Java 8 and Interface Enhancements
 Introduction to Java 8
 Default Methods and Functional Interfaces
 Creating Default Methods
 Understanding the Importance of Default Methods
 Defining a Default Method
Overriding Default Methods
 Using Inheritance with Default Methods
Working with Single Inheritance
Working with Multiple Inheritance
Understanding how Diamond Inheritance Works
 Resolving Overridden Default Methods
 Using Default Methods
Extending Existing Interfaces
Using Default Methods to Supplement Adapter Classes
Using Default Methods in Core Java Classes
Using a Class to Support Default Methods
 Understanding the Difference between an Abstract Class and Interfaces
 Using Static Interface Methods
 Functional Interfaces
Creating a Functional Interface
Using the @FunctionalInterface Annotation
Overriding Object Class Methods in a Functional Interface
Using Functional Interfaces in the Core Libraries
Chapter 2 - Lambda Expressions
 Understanding Lambda Expressions
Inferring the Type of the Target
 Creating Lambda Expressions
Lambda Expression Syntax Rules
Declaring Parameter Types
Mixing Parameter Declarations
Omitting Parentheses
Eliminating the Block Statement
Using Multiple Statements in a Lambda Expression Body
Using a Return Value
Writing Succinct Lambda Expressions
Capturing Variables in a Lambda Expression
Differentiating between a Lambda Expression and a Closure
Method and Constructor References
Using Static Method References
Using Instance Method References
Using Constructor References
 Working with Lambda Expressions
Using Lambda Expressions with Variable Declarations
Using Lambda Expressions as a Return Value
Using Exceptions with a Lambda Expression
Using Lambda Expressions with the Tertiary Operator
Casting Lambda Expressions
Using Lambda Expressions to Initialize an Array
Writing Recursive Lambda Expressions
 Using the java.util.function Functional Interfaces
Using the Predicate Interface
Using the Function Interface
Using the BiFunction Interface
Using the Consumer Interface
Using the Supplier Interface
Using Operator Type Interfaces
Using the UnaryOperator Interface
Using the BinaryOperator Interface
Chapter 3 - Streams
Stream Characteristics
Streams Do Not Store Elements
Streams Can Be Unbounded
Streams Do Not Modify the Original Source
A Stream May Be Ordered
Automatic Parallelization
An Overview of Stream Methods
 Creating a Stream
Using the Stream Interface's of Method
Using the Collection Class' stream Method
Using a Stream.Builder Interface
Using the builder method
Generating Infinite Streams
Using the iterate Method
Concatenating Streams
Generating an Empty Stream
 Using Stream Methods
The Part Example Class
Using the forEach Method
Using the forEachOrdered Method
Using the map Method
Using Other Map Methods
Using the flatmap Method
Using the filter Method
Using the Match Type Methods
Using the findFirst Method
Using the findAny Method
Using the Optional Class
Using the reduce Method
Using the Collector Interface and the collect Method
Using the Collects Class
Using the iterator Method
Using the sorted Method
Using the distinct Method
Using the limit Method
Using the skip Method
Using the max, min, and count Methods
 Streams for Primitive Types
Using the IntStream Interface
 Understanding Lazy and Eager Evaluation
Using Short-Circuit Methods
 Using Parallel Stream Operations
Chapter 4 - Date and Time
Why a New API?
A Simple Example
The ISO-8601 String Format
Design Considerations
Understanding the Standard Method Names
Understanding the of Type Methods
Understanding the from Method
Understanding the parse Method
Understanding the format Method
Understanding the get Type Method
Understanding the is Type Methods
Understanding the with Type Methods
Understanding the plus Type Methods
Understanding minus Type Methods
Understanding the to Type Methods
Understanding the at Type Methods
Overview of the Date and Time Packages
 Getting the Current Time
Working with the Instant Class
Creating an Instant
Creating an Instant Based on the Epoch
Creating an Instant Based on Parsing a UTC String
Creating an Instant by Adding or Subtracting a Time from an Instant
Using the Instant Class' get Type Methods
Working with Time Intervals
Creating Offsets Using the of Type Methods
Creating Offsets Using the with Type Methods
Creating a Duration Using the parse Method
Creating a Duration by Adding or Subtracting a Unit
Using the Duration Class
Using the Period Class
 Using Date and Time Classes
Creating Date and Time Classes
Date and Time get Type Methods
Adjusting a Date or Time
Using the YearMonth, MonthDay, and Year Classes
Comparing MonthDay Instances
Using the Enumerations DayOfWeek and Month
Using the DayOfWeek Enumeration
Using the Month Enumeration
 Working with the Time Zone and Offset Classes
Obtaining Available Zone Ids
Working with ZoneOffsets
Working with Zone Rules
 Formatting, Queries, and Value-Based Classes
Formatting Dates and Times
Using Temporal Queries
Understanding Value-Based Classes
Chapter 5 - Odds and Ends
 Using the Nashorn JavaScript Engine
Accessing the Nashorn Engine
Executing JavaScript Code
Executing Java Code from JavaScript
Implementing a Java Interface
 File IO Enhancements
Using the FileFilter Interface
Using the PathMatcher Interface
Using the Files Class' list Method
Using the Files Class' walk Method
Using the Path Class' lines Method
 Concurrency Enhancements
Using the Arrays Class' parallelSort Method
Using the Arrays Class' parallelSetAll Method
Using the Arrays Class' parallelPrefix Method
 Collections Enhancements
Using the forEachRemaining Method
Using the replace Type Methods
Using the compute Type Methods
 Project Jigsaw and Compact Profiles
  The Compact Profiles
Using Compact Profiles
 Other Enhancements
Javadoc Enhancements
Security Enhancements
VM Related Enhancements
Core Java Enhancements
Appendix A - Date and Time Classes
 Of Type Methods
 The from Method
 The parse Method
 Get Type Methods
 Is Type Methods
 With Type Methods
 Plus Type Methods
 Minus Type Methods
 To Type Methods
 At Type Methods