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

 

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

Write a method that accepts a string 'str' and the number of times to repeat that string 'count'. Return a new string with 'str' occurring 'count' times with a space between each occurrence of 'str'. There must NOT be a space before the first copy of 'str' nor after the last copy of 'str'. Note that 'count' could be zero, in which case return an empty string.


feb5_2016_APSLHL_duplicateString("test", 3) → "test test test"
feb5_2016_APSLHL_duplicateString("nothing", 0) → ""
feb5_2016_APSLHL_duplicateString("win", 1) → "win"

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

public String feb5_2016_APSLHL_duplicateString(String str, int count) { }

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