October 2019
Intermediate to advanced
434 pages
11h 54m
English
Let's start off by taking a look at how to create a very simple class to represent an online course. The following snippet demonstrates how to define a new class called Course:
class Course { // empty class body}
This new Course class currently contains no user-defined properties or methods but can be instantiated, and common methods such as toString() and hashCode() can still be invoked from any instance.
The following snippet shows how to instantiate an instance of Course from Kotlin:
val course = Course()val displayString = course.toString()
Notice that there is no need to use the new keyword, or any other keyword, to instantiate the class. We can simply use the class name and provide any required argument values.
Our ...
Read now
Unlock full access