Constructors in Kotlin

Basically, the constructors in Kotlin can be categorized as the Primary Constructor and the Secondary Constructors. In other words, a class in Kotlin can have a primary constructor and one or more secondary constructors. Creating Constructors in Kotlin While a class in Kotlin can have one primary constructor, it can include several secondary constructors. For the purpose of creating secondary constructors, …

Creating Classes in Kotlin

In this article, I will explain how to create Classes in Kotlin. Like other programming languages, the class keyword is used to define a class in Kotlin. Moreover, classes in Kotlin can have properties, methods, and constructors as its members. The following code shows the syntax of creating classes in Kotlin. Unlike Java, it is not mandatory to have …

Variable Declaration in Kotlin

In this article, I will demonstrate several examples of the Variable Declaration in Kotlin. As a matter of fact, Kotlin was developed for Java Virtual Machine (JVM). Therefore Java and Kotlin are interoperable. Further, Kotlin has been used for Android app development. In general, Kotlin creates variables in two ways – using the val, and var keywords. …