Package in Java

A package is a collection of similar types of classes, interfaces, and sub-packages. and in normal computer language, it is called a folder that contains the classes.

Purpose of package

The purpose of package concept is to provide common classes and interfaces for any program separately. In other words, if we want to develop any class or interface which is common for most of the java programs than such common classes and interfaces must be place in a package.

 

java package

Packages in Java are the way to organize files when a project has many modules. Same like we organized our files in Computer. For example, we store all movies in one folder and songs in other folders, here also we store the same type of files in a particular package for example in awt package have all classes and interfaces for design GUI components.

Advantage of package

  • Package is used to categorize the classes and interfaces so that they can be easily maintained
  • Application development time is less because reuse the code
  • Application memory space is less (main memory)
  • Application execution time is less
  • Application performance is enhanced (improve)
  • Redundancy (repetition) of code is minimized
  • A package provides access protection.
  • Package removes naming collision.

Type of package

Package are classified into two type which is given below.

  1. Predefined or built-in package
  2. User-defined package

Predefined or built-in package

These are the package which are already designed by the Sun Microsystem and supply as a part of java API, every predefined package is collection of predefined classes, interfaces and sub-package.

User defined package

If any package is design by the user is known as user defined package. User defined package are those which are developed by java programmer and supply as a part of their project to deal with common requirement.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: