Oop Present
Oop Present
The users of the Java language can also create their own packages.
They are called user-defined packages. User defined packages can
also be imported into other classes & used exactly in the same way as
the Built in packages.
We must first declare the name of the package using the package
keyword followed by the package name. This must be the first
statement in a Java source file. Then define a classes as normally as
define a class.
Example :
package myPackage;
public class class1
{
- - - - - - - - - - - - -
// Body of class1
}
How to use this package in another program.
ACCESSING A PACKAGE
Java package can be accessed either using a fully qualified
class name or using a shortcut approach through the import
statement.
Syntax :
import package1[.package2][.package3].classname;