Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

exports

Example

Include exports in the module-info.java file of a module:

module mymodule {
  exports com.code7school.package1;
  exports com.code7school.package2 to module1, module2;
}

Definition and Usage

The exports keyword enables a package from a module to be accessible by other modules.

By adding the to keyword, the exported package can be restricted to usage only by the specified modules.

Note: The exports keyword is a module directive intended to be used in a module’s module-info.java file.

The exports keyword was introduced in Java 9.