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

 

replaceEvery2ndString


Write a method called replaceEvery2ndString, which is given three Strings as input parameters. The method should return the first String which was passed to the method with every second occurrence of the second String replaced in the first String with the third String. For example replaceEvery2ndString("Mississippi", "iss", "3") would return "Miss3ippi".


replaceEvery2ndString("Mississippi", "iss", "3") → "Miss3ippi"
replaceEvery2ndString("Honolulu", "o", "O") → "HonOlulu"
replaceEvery2ndString("banana", "a", "ii") → "baniina"

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

public String replaceEvery2ndString(String s1, String pat, String repl){ }

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