Package net.jrodolfo.java_evolution.java08
package net.jrodolfo.java_evolution.java08
Examples for features introduced in Java 8.
Java 8 was a major release for day-to-day Java programming. It introduced lambda expressions, method references, the Stream API, Optional, default methods, CompletableFuture, and the modern Date and Time API.
The classes in this package intentionally avoid features from later Java versions so each example stays focused on what Java 8 added.
For a beginner-oriented explanation of the problems these features solved, see the package README in the source directory.
-
ClassDescriptionDemonstrates
CompletableFuture, introduced in Java 8 to make asynchronous work easier to compose.Demonstrates the Date and Time API introduced in Java 8 underjava.time.Demonstrates default methods, introduced in Java 8 so interfaces could evolve without forcing every existing implementation to add new methods immediately.Implementation that overrides a default method while keeping the others.Interface with one abstract method and two default methods.Implementation that inherits all default behavior fromDefaultMethodExamples.Named.Demonstrates lambda expressions, one of the main language features introduced in Java 8.Simple functional interface used to demonstrate passing behavior into a method.Demonstrates method references, introduced in Java 8 as a compact syntax for lambdas that only call an existing method or constructor.Simple formatter used to demonstrate a bound instance method reference.Small Java 8-style data class used by constructor reference examples.DemonstratesOptional, introduced in Java 8 as a container for values that may be absent.Small Java 8-style data class used by the Optional examples.Demonstrates the Stream API introduced in Java 8.Small Java 8-style data class used by the stream examples.