Base Class Initialization

This Atom is Under Construction

When a class inherits another class, Kotlin guarantees that both classes are initialized properly.

Kotlin guarantees correct object creation by ensuring that constructors are called: Not just constructors for member objects and the derived-class parts of an object, but also the constructor for the base class.

In our Inheritance examples, the base classes didn’t have constructor arguments. If a base class does have constructor arguments, any class that inherits from that base must provide those arguments during construction.

End of sample. See AtomicKotlin.com for full early-access book.



Previous          Next

©2018 Mindview LLC. All Rights Reserved.