Thursday, July 2, 2009

The import statement

The import statement taks the following form:

import [..;

or

import[.].*;
When you want to use packages ,use the import statement to tell the compiler when to find classes

eg: import java.util.*; // thats a predefined packages being imported

eg: import shipping.domain.*; // thats a user-defined package

Remember that the import statement is used to make classes in other packages accessible to the current class.

If you want to only access the Writer class from the java.io package then you would use:

import java.io.Writer;

if you want to access the whole class from java.io package then you would use:

import java.io.*;

No comments: