Write a recursive method called repeat that accepts a string and an integer as parameters and that
Question:
Write a recursive method called repeat that accepts a string and an integer as parameters and that returns concatenated together times. For example, repeat("hello", 3) returns "hellohellohello", and repeat( "ok", 1) returns "ok", and repeat( "bye", 0) returns "". String concatenation is an expensive operation, so for an added challenge try to solve this problem while performing fewer than concatenations.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Question Posted: