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

 

quiz2022_03_01_APSLHL_replaceSpace


Write a method that returns string 'txt' but with all the spaces replaced with 'replacement'. As a precondition you may assume that a space will never be followed immediately by another space. Look at the test data for examples.


quiz2022_03_01_APSLHL_replaceSpace("We might even replace single spaces with multiple characters!", "</>") → "We</>might</>even</>replace</>single</>spaces</>with</>multiple</>characters!"
quiz2022_03_01_APSLHL_replaceSpace("Orlando City Lions", "!") → "Orlando!City!Lions"
quiz2022_03_01_APSLHL_replaceSpace(" a space could be at the start and/or the end ", "~") → "~a~space~could~be~at~the~start~and/or~the~end~"

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

public String quiz2022_03_01_APSLHL_replaceSpace(String txt, String replacement) { }

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

Copyright Nick Parlante 2017 - privacy