Module import declarations
Import all exported packages of a module with a single declaration.
Porównanie kodu
✕ Java 8
import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path;
✓ Java 25+
import module java.base; // All of java.util, java.io, java.nio // etc. available in one line
Widzisz problem z tym kodem? Daj nam znać.
Dlaczego nowoczesne podejście wygrywa
One line
Replace a wall of imports with a single module import.
Module-aware
Leverages the module system to import coherent sets of packages.
Quick starts
Perfect for scripts and prototypes where import lists are tedious.
Stare podejście
Many Imports
Nowoczesne podejście
import module
Od JDK
25
Poziom trudności
Średniozaawansowany
Wsparcie JDK
Module import declarations
Dostępne
Finalized in JDK 25 LTS (JEP 511, Sept 2025).
Jak to działa
Module import declarations let you import everything a module exports with one line. This is especially useful for java.base which covers collections, I/O, streams, and more.
Powiązana dokumentacja