❮ Java Keywords
Example
Use exports in a module's module-info.java file:
module mymodule {
exports com.example.package1;
exports com.example.package2 to module1, module2;
}Definition and Usage
The exports keyword allows a package from a module to be used by other modules.
If the to keyword is added, the exported package is only allowed to be used by the modules that are listed.
Note
The exports keyword is a module directive meant to be used in the module-info.java file of a module.
The exports keyword was new in Java 9.
❮ Java Keywords