From the course: Moving Your iOS App to Android Using Kotlin

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Classes: Properties

Classes: Properties

- [Instructor] Before we dive into inheritance, let's first talk about classes and how we can create our objects. We're going to add a method. We'll say runClassesExamples. I'll hit Alt + Enter and create this function. And I'll move this out of this class. Put this down into her just to keep things a little more organized. Now let's go into our Classes KT file. We have several different sections and points of discussion to talk about here. The easiest one is to work with the basics. Classes in Kotlin are very similar to those in Swift. We can say class Person. We have something called a header constructor. Right now we'll just say constructor, firstName, and String. You can tell immediately these braces are gray. That means that they are not even required. If you don't have a body for a class, you don't need the braces. But this first name is an argument that goes into the constructor. It doesn't actually get stored as a property. There is a way to do this in that class header. We'll…

Contents