Skip to content

Instantly share code, notes, and snippets.

@cbetta
Created January 12, 2016 10:20
Show Gist options
  • Save cbetta/cc50436ace788cb7519d to your computer and use it in GitHub Desktop.
Save cbetta/cc50436ace788cb7519d to your computer and use it in GitHub Desktop.
public String reverse(String input) {
if (input.length() == 1) return input;
String lastChar = input.substring(input.length()-1);
String rest = input.substring(0, input.length() - 1);
return lastChar + reverse(rest);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment