What’s New in Java 8

What’s New in Java 8

Duration: 3 Days

Description

This course explores the transformative features introduced in Java 8, one of the most significant updates to the Java programming language. Participants will gain hands-on experience with lambda expressions, the Stream API, functional interfaces, default methods, and the new Date and Time API. Through practical exercises and real-world examples, learners will understand how these features enable more expressive, concise, and maintainable code while embracing functional programming paradigms alongside traditional object-oriented approaches.

Audience

This course is designed for Java developers who are familiar with Java 7 or earlier versions and want to modernize their coding practices. It is ideal for development teams migrating legacy codebases to Java 8, professionals seeking to write more efficient and readable code, and developers preparing for roles that require current Java expertise.

Objectives

  • Write lambda expressions and method references to replace anonymous inner classes
  • Utilize functional interfaces from the java.util.function package
  • Process collections efficiently using the Stream API and stream operations
  • Apply default and static methods in interfaces to extend functionality
  • Work with the new Date and Time API for robust temporal data handling
  • Leverage Optional to handle null values safely and expressively
  • Use parallel streams to improve performance on multi-core systems
  • Refactor legacy code to take advantage of Java 8 features

Prerequisites

Participants should have solid Java programming experience, including strong knowledge of classes, interfaces, inheritance, and collections. Familiarity with Java 5, 6, or 7 syntax is expected. Completion of an intermediate Java course or equivalent professional experience is recommended.

Course Outline

Module 1: Lambda Expressions

  • The Need for Lambdas
  • Lambda Syntax and Structure
  • Functional Interfaces
  • Lambda Expression Examples
  • Variable Capture and Effectively Final

Module 2: Method References

  • Method Reference Syntax
  • Types of Method References
  • Constructor References
  • When to Use Method References vs Lambdas

Module 3: Functional Interfaces in java.util.function

  • Predicate
  • Function and BiFunction
  • Consumer and BiConsumer
  • Supplier
  • Operator Interfaces

Module 4: Stream API Fundamentals

  • Introduction to Streams
  • Creating Streams
  • Intermediate Operations — filter, map, flatMap
  • Terminal Operations — collect, forEach, reduce

Module 5: Advanced Stream Operations

  • Sorting and Distinct Operations
  • Matching and Finding Operations
  • Stream Statistics and Summarization
  • Collectors and Custom Collectors
  • Parallel Streams

Module 6: Interface Enhancements

  • Default Methods
  • Static Methods in Interfaces
  • Multiple Inheritance of Behavior
  • Conflict Resolution

Module 7: Date and Time API

  • Problems with Legacy Date Classes
  • LocalDate, LocalTime, and LocalDateTime
  • ZonedDateTime and Instant
  • Period and Duration
  • Formatting and Parsing Dates

Module 8: Optional and Other Enhancements

  • The Optional Class
  • Working with Optional Values
  • Chaining Optional Operations
  • Repeating Annotations
  • Type Annotations