"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
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."
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.