Home > Java > javaTutorial > body text

What are the advantages of modules in Java 9?

WBOY
Release: 2023-09-10 11:37:02
forward
831 people have browsed it

Java 9中模块的优势是什么?

##Module is a software package container designed for reuse. Each module contains a module descriptor, which contains information about the module name , module dependencies (the names of other modules it depends on) and the names of the packages it exports , these Packages can only be used by dependent modules

Advantages of modules

  • Strong encapsulation is one of the main advantages of the module system because "public " access specifier is no longer accessible to everyone. By using the module system, we can allow external applications to access a limited set of packages.
  • It makes our application
  • lightweight so it can be run on a greater number of devices. Since it is lightweight, it improves the performance of the application.
  • This architecture allows us to separate the application into
  • external and hidden packages, making it easy to follow the separation of concerns principle. Some internal classes in
  • packages such as
  • sun.security.*, com.sun .crypto.* are no longer accessible because these packages are now Hidden, thus increasing security.

p>Modules can be declared in a file named "

module-info.java", which is the module descriptor .

<strong>module com.tutorialspoint.app{
   // Modules upon which the module "com.tutorialspoint.app" depends on 
   requires com.tutorialspoint.services;
   // Packages exposed by this module that can be used by other modules 
   exports com.tutorialspoint.app.util;
}</strong>
Copy after login

The above is the detailed content of What are the advantages of modules in Java 9?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template