我爱编程

kotlin open

2018-06-20  本文已影响0人  Smallmeng

The open annotation on a class is the opposite of Java's final: it allows others to inherit from this class. By default, all classes in Kotlin are final, which corresponds to Effective Java, 3rd Edition, Item 19: Design and document for inheritance or else prohibit it.

若类想要被继承,需要增加open修饰字符,kotlin中类默认不可继承

上一篇 下一篇

猜你喜欢

热点阅读