(Optional view, complementing the other answers :)
One of the main factors underlying the encapsulation of Java fields was the uniform access policy, i.e. you did not need to know or care about whether something was implemented simply as a field or calculated on the fly. The big disadvantage of this is that the supporting class in question can switch between them as needed, without the need to change other classes.
In Java, this required that everything be accessible using a method in order to provide syntactic flexibility to calculate the value, if necessary.
In Scala, methods and fields can be accessed through the equivalent syntax - so if you have a simple property, there is no loss in encapsulation to expose it directly, since you can choose it as a method without an argument later without your callers who need to know anything about this change.
source share