java package
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
Post a Comment