System.in
is an InputStream
which is typically connected to keyboard input of console programs.Here's how you can use it to read stuff from your keyboard:
var keyboardInput = new Scanner(System.in);
while (keyboardInput.hasNext()) {
System.out.printf("You have typed: %s%n", keyboardInput.next());
}
Run it, then type something to the console and hit Enter
.
Every time your input will be echoed back to you.