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

 

jebbert@volusia.k12.fl.us > dec18_2015_APSLHL_countOccurances
prev  |  next  |  chance

Write a method that returns the number of times 'target' occurs in 'str'. Overlapping is allowed. This method should be case-sensitive, so if the case does not match it does not count as a match. The 'target' string will NOT be longer than 'str'. If 'target' is an empty string return 0 since you cannot match something that does not have any characters in it.


dec18_2015_APSLHL_countOccurances("", "") → 0
dec18_2015_APSLHL_countOccurances("you cannot find it here", "") → 0
dec18_2015_APSLHL_countOccurances("Here is some test data. Happy testing.", "test") → 2

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

public int dec18_2015_APSLHL_countOccurances(String str, String target) { }

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: 280

Copyright Nick Parlante 2017 - privacy