Java Reference
In-Depth Information
As you can see, inside the
MyClass
class,
alpha
is specified as
private
,
beta
is expli-
citly specified as
public
, and
gamma
uses the default access, which for this example is the
same as specifying
public
. Because
alpha
is private, it cannot be accessed by code outside
of its class. Therefore, inside the
AccessDemo
class,
alpha
cannot be used directly. It must
be accessed through its public accessor methods:
setAlpha( )
and
getAlpha( )
. If you were
to remove the comment symbol from the beginning of the following line,