Skip to content

Instantly share code, notes, and snippets.

@dgodfrey206
Created January 31, 2015 01:18
Show Gist options
  • Save dgodfrey206/401a207e1951717f8e48 to your computer and use it in GitHub Desktop.
Save dgodfrey206/401a207e1951717f8e48 to your computer and use it in GitHub Desktop.
Java recursion #2
public int countX(String str) {
return str.isEmpty() ? 0 : countX(str.substring(1, str.length())) + ((str.charAt(0)=='x') ? 1:0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment