October 2018
Intermediate to advanced
370 pages
9h 15m
English
In Kotlin, a class can be defined with the class keyword. Let's take a look at how to declare a class and how to add attributes to it. In Kotlin, a class can be declared as follows:
class Person
Compared to other programming languages, creating a class in Kotlin is very easy. All we need to do is open our IDE and create a person class with three attributes—name, age, and height. The name is a variable of the String type, age is a variable of the Integer type, and height is a variable of the Double type:
class Person { var name: String var age : Int var height : Double }
We have now declared a Person class with three attributes enclosed in brackets. After writing this code, we will notice that compiler has immediately
Read now
Unlock full access