Swapping first and second word in a string, Java

Viewed 33

I'm currently trying to complete a Kattis problem, where I have to swap the first and second word in a string, like this example: Input: "Can I drink water." Output: "I can drink water."

I can't seem to figure out how to solve this problem, does anyone have a good and easy to understand solution?

Thanks in advance.

0 Answers
Related