Question: Write a recursive method String reverse(String s) that returns the reverse of s. For example, if s is Hello world then the method would return

Write a recursive method String reverse(String s) that returns the reverse of s. For example, if s is "Hello world" then the method would return "dlrow olleH". Hint: remove the first character c at index 0 of s forming a substring t which consists of the characters at indices 1, 2, 3, ..., s.length()-1 of s; then concatenate the reverse of t and c and return this new string.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!