You need to read up on what a recursive function is. That isn't what you wrote/found/copied there.
I'm also wondering how closely you've looked at your outputs, given this particular line in your function
return s;
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
this will do the trick:
static String reverse(String userInput)
{
String temp = "";
if(userInput.length() >= 1)
{
temp = userInput.substring(userInput.length()-1, userInput.length());
temp += reverse(userInput.substring(0, userInput.length()-1));
}
return temp;
}
Zetlin
Junior Poster in Training
66 posts since Jul 2008
Reputation Points: 22
Solved Threads: 10