Homework Help Question & Answers

Recursive string reverse tail reverse(s.substring (1, s.length())ג + s.substring(0,1) first chara...

Please create a functioning Java program which includes the following:

Recursive string reverse tail reverse(s.substring (1, s.length())ג + s.substring(0,1) first character tail reversed by recurs

Recursive string reverse tail reverse(s.substring (1, s.length())ג + s.substring(0,1) first character tail reversed by recursive call
0 0
Next > < Previous
ReportAnswer #1
//Main.java
public class Main {
  public static String reverse(String s){
    if(s==null || s.length() == 0){
      return "";
    }
    else{
      return reverse(s.substring(1,s.length()))+s.substring(0,1);
    }
  }

  public static void main(String[] args) {
    System.out.println(reverse("hello"));
  }
}

Output:

olleh

Please up vote the solution if it helped. Thanks!

Know the answer?
Add Answer of:
Recursive string reverse tail reverse(s.substring (1, s.length())ג + s.substring(0,1) first chara...
Your Answer: Your Name: What's your source?
Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
Need Online Homework Help?
Ask a Question
Get FREE Expert Answers
WITHIN MINUTES