I have a java class with: ``` protected X event; p...
# announcements
y
I have a java class with:
Copy code
protected X event;
public Y getEvent()
How do I call them from Kotlin (extending the class)?
s
classInstance.event
If you mean to access the field, I'm pretty sure the only way would be to rename the field to something like
_event
y
Overload resolution ambiguity
s
yeah, i've never come across this scenario before. If this is from a library, I'd guess there's a work around for it.
y
I'm doing a presentation about Kotlin for the company, and I want to convert some of the code for a showcase. I guess I'll have to rename the field.
f
Have you tried having intellij convert the code?
y
I've renamed it but it would have been impossible to keep the original class Java .
f
Copy code
open class BaseClass {
    protected var event: Int = 0

    fun getEvent(): String {
        return event.toString()
    }
}


class SubClass : BaseClass() {
    val fromSuperClass: Int
        get() = event
}
y
Yes that would work but not if you keep the original class Java