Conclusion
In this lesson, you’ve scratched the surface of interfaces, which enable you to model behavior that isn’t connected to inheritance.
You learned:
- That interfaces offer a flexible way to define blueprints for methods, properties, and requirements, allowing your code to adapt and be more reusable.
- About abstract classes and how you can define methods and properties that child classes should adopt. However, a class can only extend one class since Kotlin does not support multiple inheritance.
- That, unlike traditional inheritance, classes can adopt multiple interfaces as necessary.
- About the Kotlin Standard Library, which provides us interfaces such as
Comparable, which you used in this lesson. - You can define your own interfaces to create reusable code that defines the data or functionality to adopt.
- That properties in abstract classes can maintain state while properties in interfaces can’t.