Sealed classes restrict which classes can extend/implement them (`permits`). This makes class hierarchies explicit and enables exhaustive `switch` in newer Java versions. It’s useful for modeling closed sets of variants.
Expanding on the short answer — what usually matters in practice:
A tiny example (an explanation template):
// Example: discuss trade-offs for "what-are-sealed-classes-in-java-and-why-use-them"
function explain() {
// Start from the core idea:
// Sealed classes restrict which classes can extend/implement them (`permits`). This makes cl
}