I have seen mentions of new classes and methods for interacting with a console in a Java app. Like this:
You shouldn't use
Scannerat all, really. It's not meant for keyboard input, and it has bizarre API. In that the API does exactly what its spec says, but if you think 'Scanner - that's the keyboard, right?' the spec of scanner is bizarre. See the usual confusion about mixingnextLineandnextIntfor example. There is no good replacement right now yet, but there will be soon:java.io.IO.
I cannot find a Java JEP for these new features on the JEP index.
Yes, new console methods arrived in Java 25.
The existing Console class, and a new IO class, offer print, println, & readln methods.
The old System.out.println ( "Hello world!" ) is supplanted by the new IO.println ( "Hello world!" ).
| New 🟢 | 🔴 Old | 
|---|---|
| IO.println ( "Hello world!" ) | System.out.println ( "Hello world!" ) | 
| String input = IO.readln ( "Enter id: " ); | System.out.println ( "Enter id: ) ;String input = System.console().readLine(); | 
Yes, there is a series of JEPs adding features related to the console.
This series is part of the Paving the On-Ramp effort in recent years to make Java easier for beginner students.
java.io.IOJava 25 brings a new class, java.io.IO. This class offers these methods:
static void print ( Object obj )static void println ( Object obj )static String readln ( String prompt )Notice that these methods are static. So we can use them without instantiating the class.
So the familiar System.out.println ( "Hello world!" ); becomes:
import java.io.IO;
…
IO.println ( "Hello world!" );
Or, becomes even more brief with a static import.
import static java.io.IO.println;
…
println ( "Hello world!" );
java.io.ConsoleThese java.io.IO methods are implemented by calling upon the Console object returned from System.console(). So that Console class gains new methods, with the same signatures.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With