![]() |
Working With Packages
PrerequisitesPackages in Java are used to group related classes (as well as interfaces and exceptions). They help to organize large numbers of classes into functional groups (such as with the JDK), to control the scoping of names, and allow for hiding of utility classes.In this Magercise, the solution to the previous one will be broken up into a new package, CompanyPkg, which contains the Company and Employee classes, and the PackageTest file, which imports this package and uses it. Packages are discussed in detail in the course notes. Work LocationPerform all work for this magercise in VisualAge project MageLang Magercises, package magercises.packages. If this project does not appear in your Workspace add it from the repository (if it exists there) or create a new project using this name. Tasks
Perform the following tasks:
Do the same with the Company class. Add the necessary import statement to the PackageTest.java file. Compile the files and run the program. The .class files for the classes in the new package should be in a directory whose name is CompanyPkg. This directory should be in the same directory as the PackageTest.java file that you are compiling. Or, it may be located elsewhere, provided that the environment variable CLASSPATH includes a directory that contains the CompanyPkg directory.
|
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |