SLIDE 6 16
Package Visibility Rules
Anything declared private can only be
accessed from within the same class
Anything declared public can be accessed
from anywhere inside or outside the package
Anything not declared public or private can
be accessed from within the same package
Top-level classes cannot be declared
private
17
Using the Thinking Cap Using the Thinking Cap
Just for fun, the
example program will declare two ThinkingCap variables named student and fan.
import myclasses.325.ThinkingCap; public class Example { public static void main( ) { ThinkingCap student; ThinkingCap fan;
18
Using the Thinking Cap Using the Thinking Cap
The variables are
examples of reference variables, which means that they have the capability
ThinkingCap
create with the new
import myclasses.325.ThinkingCap; public class Example { public static void main( ) { ThinkingCap student; ThinkingCap fan; student = new ThinkingCap( ); fan = new ThinkingCap( );