id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

count


Write a recursive method 'count' that returns the number of Strings 'toFind' in the String str. If str is the empty string (""), it should return 0. No loops of any kind allowed! The string to search for 'toFind' will have at least 1 character. Both strings will be all lower case.


count("cat dog cat!", "t") → 2
count("hello there", "ss") → 0
count("brother from another mother", "th") → 3

...Save, Compile, Run (ctrl-enter)

public int count(String str, String toFind){ }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 350 Post-solution available

Copyright Nick Parlante 2017 - privacy