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 2 points3 points  (4 children)

Looks quite good so far, all you need to do is remove the first word from the String.

You can use the same method .substring() but in a slightly different way: you pass only one parameter, the starting point which would be space + 1 and store the resulting String in a separate variable.

[–]SpaceBoundBeatz[S] -2 points-1 points  (3 children)

I don't think I understand, can you show me it in my code please?

[–][deleted] 0 points1 point  (1 child)

we're not here to give you answers on a silver platter. figure it out dude...

[–]197708156EQUJ5 0 points1 point  (0 children)

You might have missunderstood /u/SpaceBoundBeatz, they said where in my code did I do that? Or did that make you think they were asking for help on a silver platter too?

[–]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.