logo CodeStepByStep logo

reverseWordOrder

Language/Type: Java string return
Related Links:

Write a method named reverseWordOrder that accepts a string s as its parameter and returns a new string with the words from s in reverse order. A word is a sequence of one or more non-space characters; words are separated by single spaces. For example, the call of reverseWordOrder("Hello what is your name?") should return "name? your is what Hello".

This problem is fairly straightforward to solve if you use the String method split. For added challenge, can you solve it without using split?

Method: Write a Java method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.