Flash cards
Review the key moves
What is the main idea behind Java exports Keyword?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
Which statement best captures the main point of this lesson?
Complete the missing token from the example code.
___ mymodule {Put the learning moves in the order that makes the concept easiest to apply.
❮ 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