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.
const
from yourconst val COL_ID
(or@JvmField
) – Aldershot