Top three ways to handle Java user input in a standalone Java app

This tutorial looks at three ways a Java app can handle input: using the Scanner, using the System's console object, and using a Swing component.

Computer programs, in their simplest form, really just do three things: First, they take input from the user; secondly, they manipulate that input in some manner; and thirdly, they send a response back to the client informing the user about how their input was handled. Interestingly, however, handling user input in a standalone Java application has always been rather onerous since it requires the use of InputStream objects and various esoteric input and output classes. Fortunately, additions to the JDK over the years have helped to simplify the task of obtaining input from the user. In this tutorial, the third in a series, we look at three of the best ways to handle user input in a simple, standalone Java application -- by using the Scanner class, the System's console object and the Swing package's JOptionPane.

Dig Deeper on JSRs and APIs