PrepZone Logo
PrepZone
Back to Java

Java · Medium

What are Sealed Interfaces? How do they enable exhaustive type hierarchies?

JavaJava 17+

Answer preview

A sealed interface (Java 17+) restricts which classes or interfaces may implement it. Combined with permits, it defines a closed, known hierarchy — essential for exhaustive pattern matching.…