Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
C HAPTER 13 ยท Packages and Imports is contained in the body of class Inner . Java would permit both accesses because it lets an outer class access private members of its inner classes. Protected members Access to protected members is also a bit more restrictive than in Java. In Scala, a protected member is only accessible from subclasses of the class in which the member is defined. In Java such accesses are also possible from other classes in the same package. In Scala, there is another way to achieve this effect, as described below, so protected is free to be left as is. The example shown in Listing 13.11 illustrates protected accesses: package p { class Super { protected def f() { println("f") } } class Sub extends Super { f()