MY mENU


Thursday, 9 February 2012

using package members


The types (Classes and Interfaces) that comprise a Package are known as the Package Members.

To use a public Package Member from outside its Package, you must do one of the followings :

- Refer to the member by its fully qualified name
- Import the package member
- Import the member's entire package

Refer to the member by its fully qualified name : However, if you are trying to use a member from a different package and that package has not been imported, you must use the member's fully qualified name, which includes the package name.

Example : bank.Icici a = new bank.Icici();

Import the package member : To import a specific member into the current Java Class, put an import statement at the beginning of the program before any type definitions, if there is any package statement in that Java Class write import statement after that package statement.

Example :
import bank.Icici;
Class Account
{
-----
-----
}

Import the member's entire package : To import all the types contained in a particular Package, use the import statement with the asterisk * .

Example :
import bank.*;
Class Account
{
-----
-----
}

No comments:

Post a Comment