Greeting the user
So far your programs have only printed stuff. Now they read input too.
With IO.readln() your program waits until the user types something and hits Enter. The typed text comes back as a String.
String name = IO.readln("Name: ");
IO.println("Hello, " + name);
Below there's an input field. Whatever is in it gets passed to the program as input — one line per answer. Try it out and type in your name!
Normally the user types live in the terminal. Here we simulate that with the text field below — each line is the answer to one question.
void main() {
String name = IO.readln("Name: ");
IO.println("Hello, " + ???);
}
In older Java code you'll often see the Scanner class for input:
Scanner sc = new Scanner(System.in); String name = sc.nextLine();
IO.readln() from Java 25 is the shorter successor — it does the same job, but without the boilerplate and without an import.
The prompt string ("Name: ") is printed before the input, without a line break.