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
Namespace
(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!
=====Java===== In [[Java (programming language)|Java]], the idea of a namespace is embodied in [[Java package]]s. All code belongs to a package, although that package need not be explicitly named. Code from other packages is accessed by prefixing the package name before the appropriate identifier, for example <code>class String</code> in <code>package [[java.lang]]</code> can be referred to as <code>java.lang.String</code> (this is known as the [[fully qualified name|fully qualified class name]]). Like C++, Java offers a construct that makes it unnecessary to type the package name (<code>import</code>). However, certain features (such as [[reflection (computer science)|reflection]]) require the programmer to use the fully qualified name. Unlike C++, namespaces in Java are not hierarchical as far as the syntax of the language is concerned. However, packages are named in a hierarchical manner. For example, all packages beginning with <code>java</code> are a part of the [[Java platform]]βthe package {{Javadoc:SE|package=java.lang|java/lang}} contains classes core to the language, and {{Javadoc:SE|package=java.lang.reflect|java/lang/reflect}} contains core classes specifically relating to reflection. In Java (and [[Ada (programming language)|Ada]], [[C Sharp (programming language)|C#]], and others), namespaces/packages express semantic categories of code. For example, in C#, <code>namespace System</code> contains code provided by the system (the [[.NET Framework]]). How specific these categories are and how deep the hierarchies go differ from language to language. [[function (programming)|Function]] and [[class (computer science)|class]] [[scope (programming)|scope]]s can be viewed as implicit namespaces that are inextricably linked with visibility, accessibility, and [[object lifetime]].
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)