Java 25 features

import module java.base explained

One import line instead of a wall of java.util and java.util.stream imports.

ModuleImport.java GitHub
import module java.base;

public class ModuleImport {
    public static void main(String[] args) {
        List<String> words = List.of("record", "sealed", "scoped");

        Map<String, Integer> lengths = new TreeMap<>();
        for (String w : words) {
            lengths.put(w, w.length());
        }
        System.out.println(lengths);

        System.out.println(words.stream().map(String::toUpperCase).collect(Collectors.joining(", ")));
    }
}

Run with JDK 25: java ModuleImport.java

import module java.base; imports every public top-level class and interface from the packages that module exports. List, Map, TreeMap, Collectors and many more are available without separate import lines.

Output

{record=6, scoped=6, sealed=6}
RECORD, SEALED, SCOPED

Watch out for