Zeek_64_JavaPackages(Understanding Encapsulation)
WHAT IS JAVA PACKAGE?
A java package is a group of similar types of classes, interfaces and sub-packages.
Package in java can be categorized in two form:
1-Built-in package
2-User-defined package
Built-in packages include java, lang, awt, javax, swing, net, io, util, sql etc.
We will have the detailed learning of creating and using user-defined packages.
There are three ways to access the package from outside the package.
- import package.*;
- import package.classname
- fully qualified name.
Advantage of Java Package
1) Java package is used to categorize the classes and interfaces so that they can be easily maintained.
(Use Eclipse IDE or Intellij and you will understand)
2) Java package provides access protection.
(giving access by keywords like private,default,public,etc We get protection)
3) Java package removes naming collision.
(If you have used more than one same name it shows message )
| Hierarchy of Package in Java |
Comments
Post a Comment