OnJava8-Examples/interfaces/SealedSubclasses.java
2021-09-20 17:33:35 -06:00

11 lines
409 B
Java

// interfaces/SealedSubclasses.java
// (c)2021 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
// {NewFeature} Since JDK 17
sealed class Bottom permits Level1 {}
sealed class Level1 extends Bottom permits Level2 {}
sealed class Level2 extends Level1 permits Level3 {}
final class Level3 extends Level2 {}