I just get started experimenting Android app using Kotlin. I just wanted to inherit Application class like this:
class SomeApp : Application {
}
But the compiler raises the warning:
and suggestion changes it to:
class SomeApp : Application() {
override fun onCreate() {
super.onCreate()
}
}
I read about primary and secondary constructors in the docs. So if super class has a primary constructor, then is it necessary to write here? like Application class has its own constructor
public Application() {
super(null);
}
then it would be necessary to have primary constructor for derived? or Can't I do something like Java way:
class SomeApp : Application {
constructor SomeApp(){
super();
}
}
or this error suggests something else? Can anyone explain me in detail? I'm very new to the language and this looks weird to me.
Edit: In java I can do the following: class SomeApp extends Application{ }
It has implicit constructor, so I do not have to write: class SomeApp extends Application{ public Application(){ super(); } }
But in kotlin do I have to define empty constructor like the following:
class SomeApp:Application(){ }
?