A package in Java is an encapsulation mechanism that can be used to group
related classes,interfaces, and sub-packages.
The dot (.) notation is used to uniquely identify package members in
the package hierarchy.
Declaring a package:
A package hierarchy represents an organization of the Java classes and
interfaces. It does not represent the source code
organization of the classes and interfaces.
package syntax has the following syntax.
package <package name>;
Using a packages:
The accessibility of types (classes and interfaces) in a package may deny access
from outside the package.
The import declarations must be the first statement
after any package declaration in a source file. The simple form of the
import declaration has the following syntax:
import < type name>;
Important packages in Java:
java.lang:
This package got primary classes and interfaces
essential for java language. It consists
of wrapper classes, Strings, Threads etc. This package
is by default imported into
every java program.
java.util:
This package contains useful classes and interfaces like
stack, linkedlist, hashtable etc
java.io:
This package handles files and input /output related
tasks.
jawa.awt:
This package helps to develop GUI. It consists of an
important sub package
java.awt.event
javax.swing:
java.net:
client-server
programming can be done using this package
java.applet:
Applets are programs
which come from a server into a client and get executed on client machine.
java.sql:
This package helps to
connect to databases like oracle and utilize them in java.
No comments:
Post a Comment