The java.io.IO class in Java 25+ (introduced via JEP 512) provides a simplified interface for console interaction. It is common to see code that prints a message to the console using IO.print(Object obj) or IO.println(Object obj) and then immediately calls IO.readln() to wait for user input. This sequence should be replaced with the single call IO.readln(String prompt).

Why is this an issue?

Using the prompt-aware overload is more idiomatic, reduces boilerplate, and explicitly links the prompt text to the input request in a single operation.

How to fix it

Remove calls to IO.print(Object obj) or IO.println(Object obj) directly followed IO.readln() with a single call to IO.readln(String prompt).

Code examples

Noncompliant code example

// Compact source file
void main() {
    // Non-compliant: manual prompt followed by readln() with no arguments
    IO.print("Please enter your username: ");
    String user = IO.readln();
    IO.println("Welcome, " + user);
}

Compliant solution

// Compact source file
void main() {
    // Compliant: The prompt is directly passed to the readln method
    String user = IO.readln("Please enter your username: ");
    IO.println("Welcome, " + user);
}

Resources

Documentation