Google News
logo
Java Packages
Packages
1) The package contains group of related classes and interfaces. 

2) The package is an encapsulation mechanism it is binding the related classes and interfaces. 

3) We can declare a package with the help of package keyword. 

4) Package is nothing but physical directory structure and it is providing clear-cut separation between the project modules. 

5) Whenever we are dividing the project into the packages(modules) the sharability of the project will be increased.
Java Images
Syntax :

Package package_name;
Ex:  package com.freetimelearning;

The packages are divided into two types
1) Predefined packages
2) User defined packages
Built-in or predefined packages:
These are the packages already designed by the SUN micro systems and supplied as a part of JDK (Java Development Kit) to simplify the task of java programmer.

Note:
Core packages of java starts with java. (For example: java.lang.*) and Advanced packages of java starts with javax. (For example: javax.swing.*)
1) java.lang:It is a predefined package, which is a collection of predefined classes and interfaces. Using these properties we can able to perform various operations like, handling of exceptions, handling of threads, handling of printing related statements, wrapper classes and there are String and StringBuffer classes to handle Strings. It is a default package for every java program. 

Syntax: 
 import java.lang.*;
In the above syntax java is the main package name and lang is the sub package name.

2) java.util: util stands for utility. This package is used to handle data structures, collection frame work and also handles date and time operations. 
Syntax: import java.util.*; 

3) java.io: io stands for input and output. This package contains streams; these are useful to store data in the form of files and also to perform input-output operations. 
Syntax: import java.io.*; 

4) java.awt: awt stands for abstract window toolkit. This package is used to develop GUI based applications. It consists of an important sub package java.awt.event, which is useful to provide action for components like push buttons, radio buttons, etc.
Syntax: import java.awt.*;
import java.awt.event.*; 

5) javax.swing: This package helps to develop GUI like java.awt. the x in javax represents that is an extended package, which means, it is a package developed from another package by adding new features to it. javax.swing is an extended package of java.awt
Syntax: import javax.swing.*; 

6) java.net: net stands for networking/network. This package is used to perform various operations in the networking based applications.
Syntax: import java.net.*; 

7) java.applet: Applets are programs which come from a server into a client and get executed on client machine on a network. Applet class of this package is useful to create and use applets.
Syntax: import java.applet.*; 

8) java.text: This package has two important classes, DateFormat to format dates and times, NumberFormat which is useful to format numeric values.
Syntax: import java.text.*; 

9) java.sql: sql stands for structured query language. This package helps to connect databases like oracle or Sybase and retrieve the data from them and use it in a java program.