A sealed class restricts which classes can extend it. Without sealing, any class in your project can subclass your base class, and you lose control over your type hierarchy.
Here is the syntax:
public sealed class Shape
permits Circle, Rectangle, Triangle {}
public final class Circle extends Shape {}
public final class Rectangle extends Shape {}
public final class Triangle extends Shape {}
The permits clause lists every allowed subclass. If someone tries to extend Shape with a class not on the list, the compiler rejects it.
Sealed classes work well with pattern matching. The compiler knows every possible subtype, so it can warn you when a switch expression misses a case.