What is a package?
A package is a kind of directory that contains a group of related classes and interfaces. Packages hides its class and interfaces in a separate directory. Java has many such packages it its library. If you want to use a classes, you have to import it into your program. If you want to use a method, then you have to import the corresponding class or interface.
A group of package is called library. Any class and interface inside a package is reusable.When a package is imported, its sub-packages are not automatically imported into a program. A separate import statement should be written to for every package or sub-package.
Classless and interfaces
There are two different types of packages.
2. User defined
Build -in Packages
Build -in packages are already available in Java. These packages provide all necessary classes, interfaces and methods to perform tasks. Some important packages are:
java.lang: This package has primary classes and interfaces for developing a basic Java program.
java.util: It has many useful collections. Date, time operations, victors...
java.awt: awt stands for Abstract Window Toolkit.This package is useful for developing GUI-color, paintings, images etc. It consists one important sub-package java.awt.event. It provides actions like select radio button, menu etc.
javax.swing: Helpful for GUI. It is an extended package of java,awt(package developed from another package by adding new features). 'x' represents it as an extended package.
java.net: Useful for authentication for network, creating sockets, to establish communication between client-server.
java.applet: Related to Java applets.
java.text: It contains two important classes. 'DateFormat' is to format date and time. 'NumberFormat' is to format numeric values.
java.sql: Helps to connects to the database like oracle, retrieve and use data in Java program.
Package created by user. User defined package can be used exactly same way as the build-in package.
The keyword to create a package is package.