Modern Java: From 8 to 25 and Beyond
Comprehensive examples and demonstrations of Java features from Java 8 through Java 25, showcasing the evolution of the Java language and platform.
- Practical Code Examples - Real-world demonstrations of modern Java features
- Comprehensive Test Suite - 160+ tests covering all major functionality
- Workshop Presentation - Complete slide deck covering Java evolution (slides.md)
- Java Tier List Presentation - Feature ranking and discussion format (slides-java-tier-list.md)
- Workshop Exercises - Hands-on labs with complete solutions (workshop-exercises.md)
- Data-Oriented Programming - Examples of records, sealed classes, and pattern matching working together
Java 8 - The Functional Revolution
- Lambda expressions and method references
- Stream API with advanced collectors
- Optional for null safety
- Default and static methods in interfaces
- CompletableFuture for async programming
Java 9-11 - Platform Maturity
- JShell (Java REPL)
- Collection factory methods (List.of(), Map.of())
- Local variable type inference (var)
- HTTP Client API
- String enhancements (isBlank(), strip(), repeat())
Java 12-17 - Language Evolution
- Text blocks for multi-line strings
- Records for immutable data classes
- Pattern matching for instanceof
- Switch expressions with yield
- Sealed classes for controlled inheritance
Java 18-21 - Modern Features
- Simple web server (jwebserver)
- Virtual threads for scalable concurrency
- Sequenced collections
- Pattern matching in switch
- Enhanced pattern matching with guards
- Unnamed variables with _ (Java 22)
- Stream Gatherers (Java 24)
- Scoped Values (finalized in Java 25 LTS)
- Module Import Declarations (Java 25)
- Flexible Constructor Bodies (Java 25)
- Primitive types in patterns (3rd preview in Java 25)
- Structured Concurrency (5th preview in Java 25; same API continues as the 6th preview in Java 26)
- Java 25 LTS - Latest Long-Term Support release with preview features enabled
- Gradle 9.6+ - Modern build tooling with Java 25 support
- JUnit 6 - Modern testing framework
- SonarCloud - Code quality analysis configured for educational code standards
# Clone the repository
git clone https://github.com/kousen/java_latest.git
cd java_latest
# Run all tests
./gradlew test
# Run a specific example
./gradlew run
# Generate code coverage report
./gradlew jacocoTestReport
📊 Running the Presentation
The repository includes a comprehensive Slidev presentation:
# Install dependencies for PDF export
npm install
# Start the presentation
npx slidev slides.md
# Export to PDF
npx slidev export slides.md --format pdf
- Start with Java 8 - ProcessDictionaryV2.java showcases functional programming
- Explore Records - See Person.java, Customer.java for data classes
- Pattern Matching - Check UseShapes.java for modern control flow
- Virtual Threads - VirtualThreadsDemo.java for scalable concurrency
- Data-Oriented Programming - Combine records, sealed classes, and pattern matching
- Review the slides - slides.md provides comprehensive coverage
- Work through exercises - workshop-exercises.md contains hands-on labs (Exercises 1-17, plus a Java 8 refresher as A1-A3 in the appendix)
- Build your solutions - Paste each exercise's scaffold into the src/test/java/exercises package (see the README there)
- Check solutions - Complete implementations in exercises.solutions package
- Practice with examples - Explore the main codebase for real-world patterns
- ProcessDictionaryV2 - Comprehensive Stream API showcase
- astro package - HTTP Client with Result pattern (sealed interfaces)
- shapes package - Sealed classes with pattern matching
- VirtualThreadsDemo - Modern concurrency patterns
# Run all tests
./gradlew test
# Run tests for a specific package
./gradlew test --tests "*interfaces*"
# Run workshop solution tests
./gradlew test --tests "exercises.solutions.*"
# Run with coverage
./gradlew test jacocoTestReport
Tests run in parallel via JUnit's configuration in src/test/resources/junit-platform.properties.
JaCoCo reports are generated in build/reports/jacoco/test/html/index.html
Kenneth Kousen
This repository is actively maintained and updated with the latest Java features as they become available.