Abstract Properties

Java developers who move to Kotlin will be used to abstract classes and abstract functions.

It is also possible to have abstract properties, odd as that may seem.

But, But, But… Why?

An abstract function declares a function signature that subclasses must implement (or themselves be abstract).

Similarly, an abstract property declares one or two function signatures that subclasses must implement:

The fact that this happens to be a property matters more to the caller, as they treat this as a perfectly normal property. From the standpoint of the subclasses, overriding the property is really there to provide implementations for the getter (and, where relevant, the setter).


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.