There is redundancy in your first example, since the definition varalready leads to the generation of getters and setters. For example, if we compile this class:
class Foo {
var foo: Int = _
}
Then javap -private Fooshows the following:
public class Foo {
private int foo;
public int foo();
public void foo_$eq(int);
public Foo();
}
, ( ), .
scala.reflect.BeanProperty ( scala.beans.BeanProperty 2.11) foo() foo_$eq(int) - var foo: Int, , . getFoo setFoo . , , , .
:
var.var, ( ) .BeanProperty , getFoo setFoo, , Java ( , foo_$eq ).