October 2019
Intermediate to advanced
434 pages
11h 54m
English
We can add properties to our classes in a couple of different ways. Let's start by adding a title property to our Course class, as follows:
class Course(courseTitle: String) { val title = courseTitle}
There are a couple of things to note here:
The primary constructor is defined by the parentheses after the class name. The primary constructor can be considered the default way of creating your class and can often be the only constructor that needs to be defined. We'll explore primary and secondary constructors in more detail later in this section in Customizing construction
Read now
Unlock full access