Home  >  Article  >  Java  >  What are the features of modules in Java 9?

What are the features of modules in Java 9?

WBOY
WBOYforward
2023-08-26 11:33:021033browse

Java 9中模块的特点是什么?

Module is a collection of code, data and resources. It is a set of related packages and types, such as classes, abstractclasses and interfaces with code, data files, and Some static resources.

The following are some features of the module.

Characteristics of modules:

  • Modules must define interfaces in order to communicate with other modules.
  • Module definitionModuleInterface and moduleimplementation.
  • The module provides a set of properties containing information.
  • Two or more modules have nested together.
  • Modules have clear, definedresponsibilities. Each function is implemented by only one module.
  • Modules must be able to be tested independently of other modules.
  • Errors in a module cannot be propagated to other modules.

If we have two modules: M1 and M2 , and a package in one module. M2 is called Pkg2. We want to be able to access it in module M1, then the following conditions must be met:

  • ModuleM1 depends on module M2, , then module M1 can specify "requires" module M2 in its declaration .
  • ModuleM2Export package Pkg2 to make it available to modules that depend on it. In the declaration of module M2 we can specify that it "exports" package Pkg2.
  • ul>

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

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete