:The Busy Java developer's Guide to Scala: Packages and Access Modifiers
The Busy Java developer's Guide to Scala: Packages and Access Modifiers Aug 6, 2008, 06 :00 UTC (0 Talkback[s]) (3960 reads) (Other stories by Ted Neward)
"While packaging (and importing) are part of the encapsulation and packaging story in Scala, a large part of it, as with Java code, lies in its ability to restrict access to certain members in a selective way — in other words, in Scala's ability to mark certain members "public," "private," or somewhere in-between.
The Java language has four levels of access: public, private, protected, and package-level access (frustratingly applied by leaving out any keyword). Scala:
* Does away with package-level qualification (in a way)
* Uses "public" by default
* Specifies "private" to mean "accessible only to this scope"
"By contrast, "protected" is definitely different from its counterpart in Java code; where a Java protected member is accessible to both subclasses and the package in which the member is defined, Scala chooses to grant access only to subclasses. This means that Scala's version of protected is more restrictive (although arguably more intuitively so) than the Java version."