| Java provides a powerful means of grouping
related classes and interfaces together in a single
unit: packages |
| |
| Packages are groups of related classes and interfaces. |
| Packages provide a convenient mechanism for managing a
large group of classes and interfaces while avoiding potential naming conflicts. |
| |
| Packages are useful for several broad reasons: |
| . They allow us to organize your classes into units.
Just as we have folders or directories on your hard disk
to organize your files and applications, packages allow us
to organize your classes into groups so that we only use
what we need for each program. |
| |
| . They reduce problems with conflicts in names.
As the number of Java classes grows, so does the likelihood
that we'll use the same class name as someone else, opening
up the possibility of naming clashes and errors if you try
to integrate groups of classes into a single program.
Packages allow you to "hide" classes so that conflicts can be avoided. |
| |
| . They allow you to protect classes, variables, and
methods in larger ways than on a class-by-class basis, as
you learned yesterday. we'll learn more about protections
with packages later today. |
| |
| . They can be used to identify your classes.
For example, if you implemented
a set of classes to perform some
purpose, we could name a package of those classes with a unique
identifier that identifies you or your organization. |
| |
| The Java API itself is implemented as a group of packages. |