How to access Kotlin companion objects from Java

Bart Friederichs :

I have this Kotlin class:

class Storage {
    companion object {
        val COL_ID = "id"
    }
}

and I want to use the COL_ID in my Java code:

doSomething(Storage.COL_ID);

but, the compiler tells me that COL_ID is private. I have tried to add public to all the elements (class, object and val), but it has no effect.

How can I access these companion object constants?

Update I think my question is different from the given duplicate, because I want to create constants, instead of a static method.

Bart Friederichs :

I added const, and everything was fine:

class Storage {
    companion object {
        const val COL_ID = "id"
    }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=150700&siteId=1