Lothar Schulz
Java Sealed Classes vs. Kotlin Sealed Classes #Slideless
#1about 2 minutes
Introducing sealed classes in Java 17
Sealed classes restrict which other classes may extend them, giving developers more control over inheritance hierarchies.
#2about 1 minute
Understanding Kotlin sealed classes as super enums
Kotlin's sealed classes act like enums that can hold state, making them powerful containers for different types of data.
#3about 13 minutes
Refactoring Kotlin code to eliminate nulls with sealed classes
A live coding demo shows how to replace nullable return types with a sealed class to explicitly handle success and failure cases.
#4about 11 minutes
Implementing sealed classes in Java to handle API results
This live coding example demonstrates creating a Java sealed class with final subclasses to manage success and failure states from an API call.
#5about 3 minutes
Using Java sealed interfaces with records for conciseness
Code is refactored from sealed classes to sealed interfaces implemented by records, significantly reducing boilerplate code.
#6about 3 minutes
Applying pattern matching in Java with switch expressions
The if-instanceof chain is replaced with a modern switch expression for exhaustive and more readable pattern matching.
#7about 3 minutes
Conclusion on Java vs Kotlin sealed class parity
Sealed classes in both Java and Kotlin are now functionally on par, so language choice can be based on other factors.
Related jobs
Jobs that call for the skills explored in this talk.
Java / Kotlin Developer in einem Cloud-Native-Stack
PROSOZ Herten GmbH
Herten, Germany
Intermediate
Senior
Matching moments
21:36 MIN
Major language enhancements from Java 12 to 17
Beam Me Up, Java! Unraveling the Warp-Speed Evolution: A Journey through Java LTS Versions 11 to 21
33:30 MIN
Examining the future of Java and its competition
Best of Java 15 and beyond—my favorite features
00:04 MIN
A high-level comparison of Kotlin and Java
Why Kotlin is the better Java and how you can start using it
24:17 MIN
Applying data-oriented programming principles in Java
Modern Java: This is not your father's Java anymore
27:37 MIN
Understanding Java's remaining unique language features
Why Kotlin is the better Java and how you can start using it
50:34 MIN
Q&A: Comparing Kotlin's ecosystem and future outlook
Why Kotlin is the better Java and how you can start using it
32:54 MIN
Achieving interoperability between Java and Kotlin code
Why Kotlin is the better Java and how you can start using it
21:53 MIN
Refactoring asynchronous code with modern Java features
Using Java 17 latest features in real world projects
Featured Partners
Related Videos
Route from Java to Kotlin
Christian Woerz
Why Kotlin is the better Java and how you can start using it
Iris Hunkeler
Best of Java 15 and beyond—my favorite features
Michael Inden
Algebraic Data Types + Pattern Matching = Elegant and readable Java code
Balkrishna Rawool
Modern Java: This is not your father's Java anymore
Ron Veen
"What´s New for Developers Moving from Java 11 to 17?"
Daniel Strmečki
Moving from Java to Kotlin
Urs Peter
The Cool Thing about Cool Things in Java 16 & 17 LTS
Mohamed Taman
Related Articles
View all articles.gif?w=240&auto=compress,format)



From learning to earning
Jobs that call for the skills explored in this talk.





QA Engineer (Kotlin Compiler Frontend)
JetBrains GmbH
Berlin, Germany
Maven
Kotlin
Continuous Integration

Senior/ Staff Software Developer (Kotlin Libraries)
JetBrains
Amsterdam, Netherlands
Senior
API
Java
Kotlin

Software Developer (IntelliJ Platform - Version Control Experience) New
JetBrains GmbH
Berlin, Germany
API
GIT
Java
Gitlab
Kotlin
+2

Senior Java / Kotlin Software Engineer - CQRS
The Next Chapter
Amsterdam, Netherlands
Remote
€8K
Senior
Java
Kafka
Kotlin
+4

Java Developer Advocate (Developer Advocacy) New
JetBrains
Amsterdam, Netherlands
Java
JUnit
Maven
Gradle
Python
+4