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

What are the features of modules in Java 9?

WBOY
Release: 2023-08-26 11:33:02
forward
1102 people have browsed it

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!

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