• The release of Java SE 15 in Sept 2020 will introduce “sealed classes” (JEP 360) as a preview feature.
  • A sealed class is a class or interface which restricts which other classes or interfaces may extend it.
  • Sealed classes, like enums, capture alternatives in domain models, allowing programmers and compilers to reason about exhaustiveness.
  • Sealed classes are also useful for creating secure hierarchies by decoupling accessibility from extensibility, allowing library developers to expose interfaces while still controlling all the implementations.
  • Sealed classes work together with records and pattern matching to support a more data-centric form of programming.

#java #language design #デベロップメント #設計/アーキテクチャ #アーティクル

Java 注目の機能:Sealed クラス
2.20 GEEK