There are two approaches to getting keyboard input from the user.
Java 5 (introduced around the beginning of 2005) introduced the java.util.Scanner class, which made console I/O easy for the first time. It's also very useful for reading from text files.
This is how normal programs interact - windows, buttons, menus, etc.
Console input is rarely used in real programs, so why do authors like to use it? There are probably two reasons: (1) It was the only standard way in Pascal, C, C++, etc. This is how the authors learned to program, and they often have written pre-Java textbooks which they've adapted to Java.
You really want to have a GUI interface, don't you? JOptionPane methods are easy and standard.