AboutNeal Ziring Expertise Almost anything about the core Java platform, with an emphasis on networking. Not familiar with JDBC or the new Java graphics APIs. [Sun Certified Java Programmer, JDK 1.1]
Experience Certified Java Programmer for JDK 1.1 and 2.0.
Question Sir,
I would like to know regaring the package concept in java.Would u please prive me the tutorial regarding package and also one example.How do I declare the user defined package in java.
Answer Samujeet,
Many good Java instructions and tutorials exist on the Web,
including ones about packages. I've included some links
at the end of this answer.
A Java Package is just a namespace for classes. Every class
belongs to a package. (Classes that are not explicitly given
a package belong to the special "unnamed" package.)
The Java compiler and Java run-time system automatically
associate packages with directories. For example, a package
named
com.sun.tools.compiler
corresponds to a directory
com/sun/tools/compiler
somewhere on your CLASSPATH or in a loaded Jar file.
For example, let's say you are writing a program for handling
drawings. You might have a package for all your graphics
primitives: Circle, Rectangle, Arc, Text, ...
So, you might define the package
chakra.graphics
and put each graphics primitive class in the package.
The class chakra.graphics.Circle would be in the file
chakra/graphics/Circle.java and
chakra/graphics/Circle.class
If you wanted to use these classes from other parts of
your code, you would need to import them.
To declare a class as belonging to a particular package, you
must use the "package" directive in your code.
package chakra.graphics;
import java.awt.*;
public class Circle extends Shape {
double radius;