Package
This is encapsulation mechanism to group related classes and
interfaces in single module. The main purposes of package are –
- To resolved naming conflict
- To improve modularity of program
- To provide security by preventing access of classes and interface to outside of package
Rules –
- If package is available in java file then first non-comment code should be package.
- There can be only one package name in java file.
Note – As java naming convention, package name should be
reverse of internet domain name. eg -
com.icicibank.loan housingloan
You can create class which is not in package. But it is
always recommended that you should declare a class in package.
Comments
Post a Comment