Skip to content

Sealed Class

Devrath edited this page Mar 8, 2024 · 13 revisions
contents
π™°πš‹πš˜πšžπš πšœπšŽπšŠπš•πšŽπš πšŒπš•πšŠπšœπšœ πš’πš— πšŠπš—πšπš›πš˜πš’πš
πš‚πšžπšπšπšŽπšœπšπš’πš—πš πšŠπš•πš• πš™πš˜πšœπšœπš’πš‹πš•πšŽ πš˜πš™πšπš’πš˜πš—πšœ 𝚘𝚏 𝚜𝚝𝚊𝚝𝚎 πšžπšœπš’πš—πš πšœπšŽπšŠπš•πšŽπš πšŒπš•πšŠπšœπšœ
π™°πšŒπšŒπšŽπšœπšœπš’πš—πš 𝚊 πšŸπšŠπš›πš’πšŠπš‹πš•πšŽ 𝚘𝚏 𝚊 πšœπšŽπšŠπš•πšŽπš πšŒπš•πšŠπšœπšœ
π™°πšŒπšŒπšŽπšœπšœπš’πš—πš 𝚊 πšπšžπš—πšŒπšπš’πš˜πš— πš’πš— πšœπšŽπšŠπš•πšŽπš πšŒπš•πšŠπšœπšœ
πšπš˜πš•πšŽ 𝚘𝚏 πšŠπš‹πšœπšπš›πšŠπšŒπš πšŸπšŠπš›πš’πšŠπš‹πš•πšŽ πš’πš— πšœπšŽπšŠπš•πšŽπš πšŒπš•πšŠπšœπšœ
π™΄πš—πšžπš– πšŒπš˜πš–πš™πšŠπš›πšŽπš πš πš’πšπš‘ πšœπšŽπšŠπš•πšŽπš πšŒπš•πšŠπšœπšœπšŽπšœ
πšπšŽπš™πš•πš’πšŒπšŠπšπš’πš—πš πšπš‘πšŽ πšŽπš—πšžπš– πšπšžπš—πšŒπšπš’πš˜πš—πšŠπš•πš’πšπš’ πšžπšœπš’πš—πš πšœπšŽπšŠπš•πšŽπš πšŒπš•πšŠπšœπšœπšŽπšœ
π™³πš’πšπšπšŽπš›πšŽπš—πšŒπšŽ πš‹πšŽπšπš πšŽπšŽπš— πš‚πšŽπšŠπš•πšŽπš πšŒπš•πšŠπšœπšœ πšŠπš—πš πš‚πšŽπšŠπš•πšŽπš π™Έπš—πšπšŽπš›πšπšŠπšŒπšŽ

Summarizing the definition

  • Sealed classes are a collection of instances while the enum is the collection of values.
  • Usage of when expression with enum.
  • Limiting the hierarchy of classes.
  • Can create multiple instances of sub-types.
  • sealed class is abstract by default
Clone this wiki locally