Java Reference
In-Depth Information
Here, pkg is the name of the package, which can include its full path, and classname is the
name of the class being imported. If you want to import the entire contents of a package,
use an asterisk ( * ) for the class name. Here are examples of both forms:
In the first case, the MyClass class is imported from mypack . In the second, all of the
classes in mypack are imported. In a Java source file, import statements occur immedi-
ately following the package statement (if it exists) and before any class definitions.
You can use import to bring the bookpack package into view so that the Book class can
be used without qualification. To do so, simply add this import statement to the top of any
file that uses Book .
For example, here is the UseBook class recoded to use import :
Search WWH ::




Custom Search