Scala getters and setters in Java class
问题 I would like to create a Java class that follows the Scala setters/getters convention. I tried following simple class, but it does not work: public class JavaA { private int a = 0; public int a() { return a; } public void a_$eq(int a) { this.a = a; } } But when I try to access it from scala: val x = new JavaA x.a = 1 and I get "reassignment to val" error message. I tried to look for this, but all issues I found where the other way around from scala to java. What is the right way to do it?