IO class for console I/O
The new IO class provides simple, concise methods for console input and output.
import java.util.Scanner;
Scanner sc = new Scanner(System.in);
System.out.print("Name: ");
String name = sc.nextLine();
System.out.println("Hello, " + name);
sc.close();
String name = IO.readln("Name: ");
IO.println("Hello, " + name);
Dramatically simpler
Two methods replace seven lines of Scanner setup, prompting, reading, and cleanup.
No resource leaks
No Scanner to close — IO methods handle resource management internally.
Beginner-friendly
New developers can do console I/O without learning Scanner, System.out, or import statements.
Finalized in JDK 25 alongside compact source files (JEP 512)
Java 25 introduces the IO class (java.lang.IO) alongside the compact source files feature. It provides static methods like println(), print(), readln(), and read() that replace the verbose combination of System.out and Scanner. IO.readln(prompt) handles both prompting and reading in a single call. The class is automatically available through java.lang in both compact source files and traditional classes.