Java Reference
In-Depth Information
Packages contain names were classes are stored.
Package pkg;
To represent multi packaging
Package pkgx [.pkgy [.pkgz]];
For example
Package java.awt.image a;
Finding of packages
There are three ways to find the packages. The java runtime system uses the working direct-
ory; if the package is contained in the sub directory then it will be discovered or you can set
the location by setting the location of class as shown .
Package mpack
It can use class path with java as well as javac to specify the location of class as shown .
C: \ myprograms\java\mpack
Access protection
For the protection of packages there are three specifiers in existence in java.
Private- cannot be seen or accessed from outside the class.
Public- it has feature to be accessed from anywhere.
Protected- this can be accessed only by classes which are sub-classes.
Package syntax
Importing a package
Search WWH ::

Custom Search