Kotlin: Cannot create an instance of an abstract class

In this tutorial, we shall learn to fix Kotlin: Cannot create an instance of an abstract class.

Following is a sample of the error you might get during compilation.

Error:(2, 27) Kotlin: Cannot create an instance of an abstract class

Solution

In Kotlin, we cannot create an instance of an abstract class.

Abstract class could only be inherited by a class or another Abstract class. So, to use abstract class, create another class that inherits the Abstract class.

Following is an example that demonstrates the usage of kotlin abstract class.