You are here
Home > Posts tagged "kotlin"

Kotlin: Inheritance

Inheritance In this post we will discuss Inheritance in kotlin with example. Inheritance provides the reusability of the previously defined functions. The previously defined class is called super(base, parent) class and the class that inherits the super class called the sub(derived, child) class. A derived class implicitly get all the parent

Kotlin: Interfaces

Interfaces In this post we will discuss Interfaces in kotlin, use of it, and how to declare interface in kotlin. Interface only have function declaration it not contains its implementation. In kotlin interface is by default open. You have to use override keyword in class to implement its function. If you

Kotlin: Companion Object

Companion Object In this post we will discuss companion object in kotlin. Kotlin not support static methods and variable so we use companion object to make variable and methods static. The companion objects are declared inside a class using companion The function declared inside a companion object are called using

Kotlin: Enum Class

Kotlin: Enum Class In this post we will discuss Enum Class in kotlin. Enumeration is a special type of class, if class is enum type then it is limited to a set of predefined constants. To declare a class as enum use enum keyword before the class Example: enum class Direction { North,South,West,East } fun main(args:Array<String>) { var

Kotlin:Data Class

Data Class In this post we will discuss Data classes with example. We frequently create a class to do nothing but hold data. Kotlin provides similar concept, called data class and marked as data. When we use data class the primary constructor only accepts property variables such as val or var

Kotlin Secondary Constructor

Kotlin Secondary Constructor In previous post we discussed kotlin classes and primary constructor. And in this post we will discuss how to defined secondary constructor in kotlin classes. Kotlin Secondary Constructor For declaration of secondary constructor use constructor keyword: class Employee {                        constructor(parent: Employee) { parent.children.add(this) } } If the class has a primary constructor, each secondary constructor

Kotlin: Classes and Primary Constructor

Kotlin: Classes and Primary Constructor In this post we will learn about classes, primary constructor in kotlin with example. Class is main building block of object-oriented programming language. same as java In kotlin also classes are created using class keyword. If you not specify access level it will be public by

Kotlin: Introduction

Introduction to Kotlin In this post we discuss about new programming language kotlin. In 2011 JetBrains release the kotlin as a new programming language for JVM. Kotlin is more suitable for android applications. You have to use IntelliIDEA software for programming. You can download it from JetBrains. After downloading you have