
3.7 The String Class
As we’ve discussed, Java provides the char primitive data type, which stores
one character. Almost every program, however, needs a data type that
stores more than one character. Programs need to process names,
addresses, or labels of many kinds. For example, many programs involve a
login procedure where the user has to enter a user ID and a password. The
program reads the user ID and password, compares them to values stored
in a database, and allows the user to continue only if the user ID and pass-
word match the database values.
To handle this type of data, Java provides a String class. Because the String
class is part of the