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

 

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

Write a method that returns a string that is just like 'str' except that every occurrence of 'replace' has been replaced with 'replaceWith'. As a precondition, you may assume that both 'replace' and 'replaceWith' will contain exactly one character. The only string methods you are allowed to use are .length, .equals, .substring, and .charAt.


test2020_10_29_APP1SLHL_replace("minions", "i", "?") → "m?n?ons"
test2020_10_29_APP1SLHL_replace("The minions are dressed as knights!", "s", "z") → "The minionz are drezzed az knightz!"
test2020_10_29_APP1SLHL_replace("ha ha ha", "a", "R") → "hR hR hR"

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

public String test2020_10_29_APP1SLHL_replace(String str, String replace, String replaceWith) { }

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

Copyright Nick Parlante 2017 - privacy