Accesos Java
Accesos Java
Access modifiers:
- public
All other classes can access it no mater which packages they are
, it can be accessed through inheritance and also by reference.
- private
It can just be accessed into the same class in which the member
was declared
- protected
It can be accessed through inheritance from any package, the acc
ess made through reference it's not allowed.
- default
It can be accessed for any other class into the same package by
inheritance as well as by reference
_______________________________________________________________________
#######################################################################
#
VISIBILITY
# PUBLIC # PROTECTED # DEFAULT # PRIVATE #
#___________________________#________#___________#__________#_________#
#######################################################################
#
From the same Class # Yes #
Yes
#
Yes # Yes #
#######################################################################
#
From any class in the # Yes #
Yes
#
Yes #
NO #
#
same package
#
#
#
#
#
#######################################################################
# From a subclass in the # Yes #
Yes
#
Yes #
NO #
#
same package
#
#
#
#
#
#######################################################################
# From a subclass outside # Yes #Yes using #
NO #
NO #
# the same package
#
#inheritance#
#
#
#######################################################################
#From any no-subclass class # Yes #
NO
#
NO
#
NO #
# outside the package
#
#
#
#
#
#######################################################################
Access control:
- Class Access
default: Only seen for other classes into the same package.
Non-Access modifiers:
strictfp
final
abstract