Interfaces
Discover Kotlin interfaces and define properties and methods for class implementation and conflicts in multi-interface scenarios.
Defining interfaces
An interface defines a set of properties and methods that a class should have. We define interfaces with the interface
keyword, a name, and a body with the expected properties and methods.
Press + to interact
interface CoffeeMaker {val type: Stringfun makeCoffee(size: Size): Coffee}
Implementing interfaces
When a class implements an interface, this class has to override all the elements defined by this interface.
Points to remember:
We can treat an instance of a class as an instance of an interface.
We implement interfaces similarly ...