java package

Packages

            Packages are nothing but Putting classes and interfaces together in a bundle or envelope.

• Package is the collection of several classes , interfaces and sub packages

• There are two types of packages in java




• Built in/In Built packages - java, java.awt, java.io



• User defined packages - MyPackage {perfume, dresses}



Keywords

• Import - import keyword is used to bring a package to the current

class

• Package – package keyword is used to define a package

                Example

import java.io.*;

package MyPack;

public class Perfume{}

public class Dress{}

# classes Perfume and Dress belongs to the package MyPack


Advantages

Java Package is used to categorize classes and interfaces to maintain easily

java Package Provides access Protection

java Package removes naming collision

Comments

Popular posts from this blog

Unit 3 : Regression

Operating System - Unit - 4 Memory Management and File Managment

Unit 1 - Introduction to Operating Sytem & Unit 2 - Process Characterization