April 2019
Beginner to intermediate
698 pages
15h 15m
English
There are two main steps involved with classes. First, we must declare our class, and then we can bring it to life by instantiating it into an actual useable object. Remember, the class is just a blueprint, and you must use the blueprint to build an object before you can do anything with it.
Classes can be of varying sizes and complexities depending upon what its purpose is. Here is the absolute simplest example of a class declaration.
Remember that we most often declare a new class in a file of its own with the same name as the class.
We will cover some exceptions to the rule throughout the rest of the book.
Let's have a look at three examples of declaring a class:
// This code goes in a file named Soldier.kt ...