Slide 16
Slide 16 text
$ ~/Downloads/jdk-19.jdk/Contents/Home/bin/jshell --enable-preview
| Welcome to JShell -- Version 19-ea
| For an introduction type: /help intro
jshell> record FruitSalad(
...> AppleVariety apple,
...> BananaVariety banana,
...> CherryVariety cherries
...> ) { }
...>
...> sealed interface FruitSnack permits Apple, Banana, Cherries { }
...> record Apple(AppleVariety variety) implements FruitSnack { }
...> record Banana(BananaVariety variety) implements FruitSnack { }
...> record Cherries(CherryVariety variety) implements FruitSnack { }
...>
...> enum AppleVariety {GOLDEN_DELICIOUS, GRANNY_SMITH, FUJI}
...> enum BananaVariety {CAVENDISH, GROS_MICHEL, MANZANO}
...> enum CherryVariety {MONTMORENCY, BING}
| created record FruitSalad, however, it cannot be referenced until class AppleVariety, class BananaVariety, and class CherryVariety are declared
| created interface FruitSnack, however, it cannot be referenced until class Apple, class Banana, and class Cherries are declared
| created record Apple, however, it cannot be referenced until class AppleVariety is declared
| created record Banana, however, it cannot be referenced until class BananaVariety is declared
| created record Cherries, however, it cannot be referenced until class CherryVariety is declared
| created enum AppleVariety
| created enum BananaVariety
| created enum CherryVariety
jshell>