October 2019
Intermediate to advanced
434 pages
11h 54m
English
Defining an interface in Kotlin is quite similar to Java. To declare a new interface, you must add the interface keyword followed by the interface name as in the following code:
interface GameObject
It's not required to provide an interface body or any methods or properties. An empty interface might be used as a simple marker interface.
We can add an interface method by defining a method signature to be required by the interface:
interface GameObject { fun update(currentTime: Long)}
A class or object can them implement this interface method. To do this, the class must include interface in its declaration and then either implement the required methods or be marked abstract. The following snippet demonstrates a ...
Read now
Unlock full access