When we have a situation where strings contain multiple pieces
of information (for example, when reading in data from a file on
a line-by-line basis), then we will need to parse (i.e., divide
up) the string to extract the individual pieces. Issues to
consider when parsing a string: We want to divide up a phrase
into words where spaces are used to separate words. For example
the music made it hard to concentrate String phrase = "the music
made it hard to concentrate"; String delims = "[ ]+"; String
tokens = phrase.split(delims); for (int i = 0; i <
tokens.length; i++) System.out.println(tokens[i]); Suppose each
string contains an employee's last name, first name, employee
ID#, and the number of hours worked for each day of the week,
separated by commas. So String employee =
"Smith,Katie,3014,,8.25,6.5,,,10.75,8.5"; String delims = "[,]";
String tokens = employee.split(delims); After this code
executes, the tokens array will contain ten strings (note the
empty strings): "Smith", "Katie", "3014", "", "8.25", "6.