Introduction
Software Requirement
JDK1.3.
- Pre Defined Package
- User-Defined Package
Pre Defined Package
Pre Defined Packages are already some of the existing packages.
Examples are,
- java.io.*;
- java.net.*;
- java.lang.*;
- java.awt.*; and etc.,
User-Defined Package
User-Defined Packages are the programs, which can define their own packages to bundle the group of classes/interfaces, etc. It is a good practice to group the related classes implemented by you so that a programmer can easily determine that the classes, interfaces, enumerations, annotations are related.
- package pack;
- public class one {
- public static void temp() {
- System.out.println("Welcome");
- }
- }
- package pack.subpack;
- public class two {
- public static void temp1() {
- System.out.println("Have a Nice Day...");
- }
- }
- import pack.*;
- import pack.subpack.*;
- class three {
- public static void main(String arg[]) {
- one.temp();
- two.temp1();
- }
- }
Explanation
In this blog, I will explain about Package concept, using Java Program. It is very simple in Java Programming. The output will be displayed in the Run module.
Output
Compile one.java in the pack directory.
Compile two.java in the sub pack directory.
Compile and execute three.java in the main directory.

Join the conversation! Your thoughts help the community grow.