What problem are you trying to solve?
JEP 512, JDK-8305457 added a new IO class to JDK 25 that is automatically imported (as it is part of java.lang). It offers convenient methods to read and write from standard input and output. While aimed at beginners, it is a concise way to print to the console, and will feel natural to anyone who started their Java journey at version 25.
What precondition(s) should be checked before applying this recipe?
JDK version >= 25
Describe the situation before applying the recipe
class A {
static void main() {
System.out.print("Please enter your name: ");
String name = IO.readln();
System.out.println("Hello " + name);
}
}
Describe the situation after applying the recipe
class A {
static void main() {
IO.print("Please enter your name: ");
String name = IO.readln();
IO.println("Hello " + name);
}
}
Any additional context
Note that IO does not offer a way to print formatted strings, so System.out.printf will remain unchanged.
What problem are you trying to solve?
JEP 512, JDK-8305457 added a new
IOclass to JDK 25 that is automatically imported (as it is part ofjava.lang). It offers convenient methods to read and write from standard input and output. While aimed at beginners, it is a concise way to print to the console, and will feel natural to anyone who started their Java journey at version 25.What precondition(s) should be checked before applying this recipe?
JDK version >= 25
Describe the situation before applying the recipe
Describe the situation after applying the recipe
Any additional context
Note that
IOdoes not offer a way to print formatted strings, soSystem.out.printfwill remain unchanged.