Modern Java Features: Sealed Classes
Sealing a class or interface restricts the list of subclasses or implementations to a predefined set. For example, consider defining a Shape and restricting subclasses to be only triangles and squares.
public class SealedClasses {
sealed class Sh...
code-like-a-woman.hashnode.dev4 min read