I have a an Interface in Java with the static variable interfaceValue
that I could access as below
public class Experimenting {
public interface MyInteface {
int interfaceValue = 10;
}
class MyImpl implements MyInteface { }
MyImpl myImpl = new MyImpl();
void testing() {
int getInterfaceValue = myImpl.interfaceValue;
}
}
When I convert to Kotlin, it is as below
class Experimenting {
internal var myImpl = MyImpl()
interface MyInteface {
companion object {
val interfaceValue = 10
}
}
internal inner class MyImpl : MyInteface
internal fun testing() {
val getInterfaceValue = myImpl.interfaceValue
}
}
However the myImpl.interfaceValue
is showing compile error sign, where by it doesn't recognize the interfaceValue
. How could I still access my interfaceValue
in Kotlin?