Java, Java8, Java21, Java17, Migration.
classes work public sealed class Shape permits Circle, Rectangle, Triangle, Square {...} public sealed class Rectangle extends Shape permits TransparentRectangle, FilledRectangle {...} In this example, the Shape class is declared as sealed using the sealed keyword. The permits keyword is used to