Java Module 4 Chapter 9
Java Module 4 Chapter 9
Defining a Package
Package: It arranges classes, interfaces, and sub packages into
a particular group.
Example –
package mypackage;
package mypackage;
package pkg1[.pkg2[.pkg3]];
Example:
package java.awt.image;
Class path
1. The Java run-time system uses the current working
directory as its starting point.
● import pkg1[.pkg2].(classname|*);
● Example
● import java.util.Date; // import Date class under java.util
● import java.io.*; // import all classes under java.io
Lab Activity/Exercise 21
Develop a JAVA program to create a package called
mypackage. Define a class in mypackage. Import the
same class with a suitable import statement and test it
in a main program.