What Are Sealed Modifiers

What is Sealed modifiers? The sealed modifier is used to prevent derivation from a class. An error occurs if a sealed class is specified as the base class of another class.

What is sealed in Java?

A sealed class is a class or interface which restricts which other classes or interfaces may extend it. Sealed classes, like enums, capture alternatives in domain models, allowing programmers and compilers to reason about exhaustiveness.

What is sealed interface?

Sealed interface allows you to control which code is responsible for implementing it. Its mean that you can use pattern matching in more safe way, because you will know that all inherited classes have some restrict. The term ‘sealed’ is very known in Scala, the JVM language.

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest