Buy the book!
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
Always using the fully-qualified name of a java class can be
tiresomely verbose. Using the full qualified name also ties the code
to a single package making code changes necessary should the class
move from one package to another. The Java
specifies that the following class declarations are in the named
package, without having to explicitly name the full package
package declaration can be
followed by zero or more
import declarations, which
allows either a single class or all the classes in a package to be
named by a simple identifier. C++ provides something similar with the
using declaration and directive.
allows the program text to refer to class-name as a shorthand for
the fully qualified name:
To achieve the same effect C++, you have to do this:
Java can also cause imports on demand, like this:
Doing this allows any class from the package package-name to be refered to only by its class-name within the program text.
The same effect can be achieved in C++ like this:
using namespace package-name;
|webmaster||delorie software privacy|
|Copyright © 2003 by The Free Software Foundation||Updated Jun 2003|