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!
====Modifiers==== Modifiers are keywords used to modify declarations of types and type members. Most notably there is a sub-group containing the access modifiers. * '''<code>abstract</code>''' - Specifies that a class only serves as a base class and cannot be instantiated. * '''<code>static</code>''' - Used only for member classes, specifies that the member class does not belong to a specific instance of the containing class. * '''<code>final</code>''' - Classes marked as <code>final</code> cannot be extended from and cannot have any subclasses. * '''<code>strictfp</code>''' - Specifies that all floating-point operations must be carried out conforming to [[IEEE 754]] and forbids using enhanced precision to store intermediate results. =====Abstract class===== {{Excerpt|Abstract type #Java}} =====Final class===== {{Excerpt|final (Java)#Final classes}} =====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)