Skip to content

Blog

87 posts · page 5 of 11

Inner class

1 min read

Inner class is like nested class, but an object of inner class maintains a reference to the outer class. inner has implicit link to outer class.

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…