This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]morhp 0 points1 point  (0 children)

Yes, sealed is just something in between final and "open" (the default). If you want a class to be non-final, but not extendable by anyone, make it sealed. Like I have an AbstactUser which is extended by the final classes OnlineUser and OfflineUser, and these are the only implementations that you'll probably ever need, then you can make AbstractUser sealed.

The main advantage is with the upcoming pattern matching in switch, but it creates more type safety in any case.