bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java exports Keyword

Flash cards

Review the key moves

1/4
Core idea

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.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___ mymodule {
3Order

Put the learning moves in the order that makes the concept easiest to apply.

Use exports in a module's module-info.
Definition and Usage
Java exports Keyword

❮ 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

Previous

Java enum Keyword

Next

Java extends Keyword