
Introduction
Up to now, whenever our programs needed data, we have supplied that
data using one of several different methods:
■
Assigning values to variables in our program. This is known as
hard coding the values of variables.
■
Prompting the user for values using the Scanner class.
■
Reading data from a text file using the Scanner class.
■
Prompting the user for values using a JOptionPane dialog box.
■
Generating random numbers using the Random class.
Typically, whenever we prompted the user to supply values, we asked for
one value at a time. If a program needs a large number of values, however,
prompting the user for each value will take a long time and ...