Issue
What alternative to an Inner static Class
can I use in Kotlin Language, if it exists? If not, how can I solve this problem when I need to use a static class
in Kotlin? See code example below:
inner class GeoTask : AsyncTask<Util, Util, Unit>() {
override fun doInBackground(vararg p0: Util?) {
LocationUtil(this@DisplayMembers).startLocationUpdates()
}
}
I've searched a lot, haven't found anything, Thank you very much in advance.
Solution
Just omit the inner
in Kotlin.
Inner class (holding reference to outer object)
Java:
class A {
class B {
...
}
}
Kotlin:
class A {
inner class B {
...
}
}
Static inner class aka nested class (no reference to outer object)
Java:
class A {
static class B {
...
}
}
Kotlin:
class A {
class B {
...
}
}
Answered By - Michael Butscher
Answer Checked By - Mary Flores (JavaFixing Volunteer)