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
Get step-by-step solutions from verified subject matter experts
