Home> Java> javaTutorial> body text

What are the advantages of modules in Java 9?

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

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

##Moduleis a software package container designed forreuse. Each module contains amodule descriptor, which contains information about themodule name,module dependencies(the names of other modules it depends on) and the names of thepackages it exports, these Packages can only be used by dependent modules

Advantages of modules

  • Strong encapsulationis 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
  • lightweightso it can be run on a greater number of devices. Since it is lightweight, itimproves the performance of the application.
  • This architecture allows us to separate the application into
  • externalandhiddenpackages, 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, thusincreasing security.

p>Modules can be declared in a file named "

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

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; }
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!