World Congress 2022 Jun 15, 2022

Java Sealed Classes vs. Kotlin Sealed Classes #Slideless

Lothar Schulz

Tired of unpredictable, null-prone code? Discover how sealed classes in both Java 17 and Kotlin eliminate nullable return types through strict hierarchies and exhaustive pattern matching.

Pause
Mute Enter Fullscreen
#1 about 2 min

Controlling class extension with Java sealed classes

Java 17 introduces sealed classes to restrict and explicitly define permitted subtypes.

#2 about 2 min

Kotlin sealed classes as flexible super enums

Kotlin sealed classes enable fixed type hierarchies that store state in subclasses.

#3 about 7 min

Refactoring API integration using Kotlin sealed classes

Replacing nullable API responses with explicit success and failure data classes.

#4 about 6 min

Applying exhaustive pattern matching in Kotlin

The when expression ensures safe handling of all possible sealed class types.

#5 about 9 min

Structuring API responses with Java sealed classes

Creating explicit success and exception subclasses improves type safety in Java API integrations.

#6 about 3 min

Evaluating object subtypes with Java instanceof

Using traditional type checking allows branching logic based on the API response type.

#7 about 4 min

Reducing boilerplate with Java sealed interfaces and records

Transitioning from standard classes to records simplifies syntax and eliminates redundant code.

#8 about 4 min

Pattern matching with Java switch preview features

Java 17 enables exhaustive type matching to handle sealed class branches safely.

#9 about 3 min

Comparing Java and Kotlin sealed class features

Both languages offer parity in sealed class capabilities and robust type matching.

Matching moments

3:03 min

Introduction to Kotlin history and Java ecosystem interoperability

Urs Peter · WWC 2022

3:01 min

Introduction to Kotlin and Java interoperability

Christian Woerz · LIVE

4:52 min

Introduction to the Java and Kotlin ecosystems

Iris Hunkeler · LIVE

1:33 min

Configuring runtime Java and Kotlin interoperability protocols

Iris Hunkeler · LIVE

1:43 min

Summarizing the practical engineering advantages of writing Kotlin

Iris Hunkeler · LIVE

3:16 min

Significant performance and language features launching in Java 21

Jonathan Vila · LIVE

Upcoming sessions on this topic

Open session

World Congress 2026 North America

Look What Java Can Do Now: Live-Coding a GenAI MCP Server with the JAQ Stack

Suren Konathala

Senior Engineering Leader, Marketing & AdTech, AI GTM & Digital Experience Platforms, Java x AI

Suren Konathala
Open session

World Congress 2026 North America

When Humans Stop Writing Code: Rethinking Languages, Compilers, and Responsibility

Simon Auer

Organizer of flutter vienna meetup and CEO of marqably

Simon Auer
Open session

World Congress 2026 North America

One Repo, One Strategy: Scalable Full-Stack Testing in a Monorepo World

Bartosz Leczycki, Paweł Matynia

Bartosz Leczycki
Paweł Matynia
Open session

World Congress 2026 North America

There's no dark factory without better software verifiers

Dexter Horthy

Co-Founder, HumanLayer

Dexter Horthy
Open session

World Congress 2026 North America

API = Some REST and HTTP, right? RIGHT?!

Rustam Mehmandarov

Passionate computer scientist

Rustam Mehmandarov
Open session

World Congress 2026 North America

Vibe Coding Accessibility

Karl Groves

Focused on actively fixing accessibility

Karl Groves