Skip to content

#kotlin

62 posts · page 3 of 8

Object Object Object

1 min read

The object keyword in Kotlin defines something like class. But you cannot create instance of an object, as there is only one. Remember [Singleton pattern][singleton].

Nested class

1 min read

A nested class enables us to group more logically, hence it makes it more readable and refined structure. A nested class is simply a class within the namespace of outer class.

Sealed class in Kotlin

1 min read

To constrain a class hierarchy, we have to declare the superclass sealed. Without the constraint, our code will look like this:

Downcasting

1 min read

Downcasting is to discover the specific type of a previously upcast object. Upcast is always safe because the base class cannot have a bigger interface than the derived class. Every base class member…

Polymorphism

1 min read

One of the Object Oriented Programming concept is the ability of polymorphism. The word, polymorphism is an ancient Greek term. It means many forms. In programming context, polymorphism means an obje…