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

 

countString2


Given a string, return the number of times that String b appears in String a. Do not count overlapping occurrences. For example, the string "xx" occurs only once in "xxx" but twice in "xxxx". For this problem please use a while loop and the indexOf method.


countString2("amy adams adds", "a") → 4
countString2("amy adams adds", "ad") → 2
countString2("eeee", "ee") → 2

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

public int countString2( String a, String b ){ }

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

Copyright Nick Parlante 2017 - privacy