Question: Repeat the previous exercise, but find the second word in the string. Previous exercise Write some Java statements that use the String methods indexOf and

Repeat the previous exercise, but find the second word in the string.


Previous exercise

Write some Java statements that use the String methods indexOf and substring to find the first word in a string. We define word to be a string of characters that does not include whitespace. For example, the first word of the string

"Hello, my good friend!"

is the string "Hello,"and the second word is the string "my".

Step by Step Solution

3.46 Rating (178 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

sentence sentencetrim int space sentenceindex... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java An Introduction to Problem Solving and Progra Questions!