Static Inner Class in Kotlin

Osama Mohammed :

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.

Michael Butscher :

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 {
    ...
    }
}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=420592&siteId=1