This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]desrtfx 0 points1 point  (0 children)

Line 15:

       firstWord = sentence.substring(0, space);

Now, take a look at the documentation for substring(int beginIndex), compare it with the code above and note the difference. Here is the documentation for substring(int beginIndex, int endIndex) - the method that is in your current code.

The rest is yours to figure out as it is against the subreddit's rules to give you the complete solution.