https://kotlinlang.org logo
d

danijoo

07/31/2016, 2:33 PM
if a java class implements this interface:
Copy code
interface Foo {
    val bar : FooBar
}
the autogenerator generates a getter for that value:
Copy code
class MyClass implements Foo {
    @Override public FooBar getBar() {
        return null; // TODO implement
    }
}
Nevertheless I can still call the property from my java code:
Copy code
this.bar.doSomething()
. What does this do internally? Will the getter be only called once when the class gets created or will getBar() be called everytime I access the property?