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
From the course: Moving Your iOS App to Android Using Kotlin
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Lambdas7m 12s
-
Exceptions6m 29s
-
Interfaces4m 1s
-
Interface conflicts4m 45s
-
Classes: Properties1m 44s
-
Classes: Constructors4m 12s
-
Types of classes3m 15s
-
Inheritance: Functions2m 30s
-
Inheritance: Properties2m 49s
-
Enums5m 36s
-
Generics5m 24s
-
Extension basics4m 26s
-
Extension imports2m 24s
-
Extension Collisions2m 45s
-
Working with Java: Marshalling types2m 18s
-
Working with Java: In Kotlin2m 39s
-
Working with Java: From Kotlin3m 16s
-
-
-
-
-