I/O beginner

IO class for console I/O

The new IO class provides simple, concise methods for console input and output.

✕ Java 8
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();
✓ Java 25+
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.

Old Approach
System.out / Scanner
Modern Approach
IO class
Since JDK
25
Difficulty
beginner
IO class for console I/O
Preview

Preview in JDK 25 as part of implicitly declared classes (JEP 495)

Java 25 introduces the IO class (java.io.IO) as part of the implicitly declared classes 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 in compact source files and can be used in traditional classes via import.

Share 𝕏 🦋 in