logo
  • 教程列表
  • SO官方文檔
  • 類繼承
    • 基礎知識 open 關鍵字
    • 繼承類的欄位
    • 從類繼承方法
    • 覆蓋屬性和方法
  1. StackOverflow 文件
  2. Kotlin 教程
  3. 類繼承
  4. 基礎知識 open 關鍵字

基礎知識 open 關鍵字

Created: November-22, 2018

在 Kotlin 中,預設情況下類是 **final,**這意味著它們不能繼承。

要允許繼承類,請使用 open 關鍵字。

open class Thing {
    // I can now be extended!
}

注意: 預設情況下,抽象類,密封類和介面將是 open。

  • 繼承類的欄位
  • 類繼承

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明