Reply to post: Sealed classes and interfaces

Java 17 arrives with long-term support: What's new, and is it falling behind Kotlin?

Anonymous Coward
Anonymous Coward

Sealed classes and interfaces

Java introduces the Sealed classes and interfaces as a preview feature in JDK 15 (JEP 360) and JDK 16 (JEP 397). Now, finalized the feature in JDK 17 (JEP 409), with no changes from JDK 16.

I have gone through this article https://tedblob.com/sealed-classes-and-interfaces-in-jdk-17/. Compared to Kotlin sealed class, this provides more control on what subclasses can extend a class. Kotlin sealed class would have package-private visibility whereas Java sealed class provides more fine-grained control.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon