Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Java syntax
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=====Access modifiers===== The ''access modifiers'', or ''inheritance modifiers'', set the accessibility of classes, methods, and other members. Members marked as <code>public</code> can be reached from anywhere. If a class or its member does not have any modifiers, default access is assumed. <syntaxhighlight lang="java"> public class Foo { int go() { return 0; } private class Bar { } } </syntaxhighlight> The following table shows whether code within a class has access to the class or method depending on the accessing class location and the modifier for the accessed class or class member: {| class="wikitable" style="text-align: center;" !width="20%"|Modifier !width="20%"|Same class or nested class !width="20%"|Other class inside the same package !width="20%"|Extended Class inside another package !width="20%"|Non-extended inside another package |- !<code>private</code> |yes |no |no |no |- !default (package private) |yes |yes |no |no |- !<code>protected</code> |yes |yes |yes |no |- !<code>public</code> |yes |yes |yes |yes |- |} [[File:JavaAccessSpecifier.jpg|thumb|This image describes the class member scope within classes and packages.]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)