Write some Java statements that use the String methods indexOf and substring to find the first word

Question:

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".

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: