Java Reference
In-Depth Information
Packages
Packages contain names were classes are stored.
Syntax
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.
1.
Private- cannot be seen or accessed from outside the class.
2.
Public- it has feature to be accessed from anywhere.
3.
Protected- this can be accessed only by classes which are sub-classes.
Package syntax
Importing a package
Search WWH ::




Custom Search