Difference Between Module and Package
The principal difference between the module and package is given below.
1. Module: In easy words, we can say that the module is a set of related applications or It is a collection of related applications such that it affords an API handy to different modules that are internal and encapsulated.
Suppose permits take an example from the built-in module in Java let’s take java.util for example. If we expect java.util as a module we recognize that there are a variety of instructions and sub-packages inside the java.util. Now we’ve assumed that java.util is a package deal the modules could be like java.util.Collections and java.util.stream.
2. Package: A package is a set of classes, interfaces, and sub-packages that are similar. There are mainly two types of packages in Java, they are:
- User Defined packages: The packages that contain the classes or interfaces which are built based on the user and it is nothing but they are just defined by the user.
- Built-In Packages: The packages that come pre-installed when we configure the Java in our system are called the built-in packages. For example, as we specified earlier such as java.net, java.awt, javax.swing, java.sql etc
Java Modules
Java Module System provides an additional layer of encapsulation to our programs as we can specify which package can be utilized by the modules, and which modules could have entry to to them. Before entering into the exclusive types of modules in Java, we will first learn the differences among applications and modules. We recognize that there are numerous applications in Java including IO bundle, AWT package, swing bundle, and so on.
Contact Us