Chapter 5
Object-Oriented Programming in Kotlin
IN THIS CHAPTER
Using classes with finesse
Working with Kotlin’s classes and interfaces
Being part of Kotlin’s inner circle
Putting your eggs (your file, that is) in a basket
Kotlin can work in the object-oriented programming (OOP) paradigm, much as Java does. It’s not limited to OOP, though. If your heart so desires, you can use it as a functional programming language, too. Chapter 3 in this minibook covers the highlights of both functional and OOP in Kotlin. That chapter focuses on the object-oriented nature of Android development, though, because that’s the topic of this book.
There are significant differences between Java and Kotlin in OOP implementation, so even if you’re familiar with Java OOP, read this chapter to prepare for future chapters on Android programming using Kotlin. This chapter covers some of object-oriented programming's finer points.
Static Fields and Methods
Listing 5-1 reproduces a small portion of the source code of Android's Toast
class from Toast.java
. (To open the file in Android Studio, right-click ...
Get Android Application Development All-in-One For Dummies, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.