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.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.