Loading topic
sealed modifier, the permits clause, and what the compiler and the JVM check when they see them. It assumes you know Java inheritance and interfaces, the final keyword, access modifiers, packages, and the basics of records and switch expressions.5 min readfinal keyword, and the basics of records and enums. It also assumes you have read the previous chapter, where a sealed type lists its permitted subclasses. Here the focus moves to the other side of that relationship: what each permitt6 min readfinal, sealed or non-sealed for each subclass. It covers two questions that come up as soon as a hierarchy spans more than one file. Where may the permitted subclasses be declared? And when can you leave out the permits clau5 min readfinal keyword, the sealed/permits syntax, and the three subclass modifiers final, sealed and non-sealed. It also assumes you have used records and enums at a basic level and have seen switch expressions. Here you learn how re6 min readsealed, permits, final and non-sealed rules from the earlier chapters. Pattern matching for switch requires Java 21 or later.5 min readsealed, permits, final and non-sealed keywords from earlier chapters. Here you will use them together as a modeling techniqu6 min readswitch for exhaustiveness. This chapter covers the syntax, the exhaustiveness behavi5 min readsealed and permits, and that you know final, sealed and non-sealed. It covers the rules that make the compiler reject code, and the cases where the JVM or the standard library refuses a sealed type at runtime. Knowing these rules help5 min readsealed, permits, final and non-sealed keywords, records, enums, and pattern-matching switch on Java 21 or later. It does not teach those again. It helps you choose between four ways to model "a thing that comes in several 6 min read