What Scala actually produces in Java bytecodes is something like this Java equivalent:
public class Kitty {
private int purrVolume;
public void setPurrVolume(int purrVolume) {
this.purrVolume = purrVolume;
}
public int getPurrVolume() { return purrVolume; }
}
Later, if you decide that you need to change it to do some special calculations in the getters and setters, you can add that to the Scala code. External users of the class will not need to be recompiled, because under the covers Scala was never actually exposing the public member variable.
public class Kitty {
private final int purrVolume;
public Kitty(final int purrVolume) {
this.purrVolume = purrVolume;
}
public int getPurrVolume() { return purrVolume; }
}