StringHelper class

  • 5
  • Locked
We love static methods. They make the inaccessible accessible. Of course, sometimes the opposite is true... But in this task, we love them: Let's create a StringHelper class that has 2 static methods: multiply(String s, int count) - returns a string that has been repeated count times; and multiply(String s) - returns a string that has been repeated 5 times.
You can't complete this task, because you're not signed in.
Comments (14)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Xavi Martin
Level 22
Expert
10 October 2022, 07:28
How do you expect us to do the task if it is not clearly explained and you have to use methods that we have not used yet?
Chloe
Level 13 , Alhambra, United States
21 October 2021, 06:48
you can use a for loop and "result+=s;"
Aron
Level 18
8 July 2021, 21:19
use a for loop to append onto the result variable
Sinisa
Level 11 , Banja Luka, Bosnia and Herzegovina
25 February 2021, 14:13
Pure confusion.
monipuff
Level 14 , United Kingdom
10 August 2020, 12:18
for loop came in handy :)
Brandon Leirer
Level 7 , Keller, United States
12 June 2020, 20:11
What's the point of String result = ""; ? Is that just to initialize 'result'? Would it have hurt anything to just write String result; ?
Vladyslav Korol
Level 16 , Coral Springs, United States
10 April 2020, 04:26
The wording of this task is misleading.
Jasey
Level 13 , Chester, United States
11 January 2020, 18:02
I solved this with the repeat method, ( tested separately ). A simple solution, however, I could not get it to compile with CodeGym.
oli blaustrom
Level 18 , Luzern, Switzerland
13 December 2019, 19:41
Actually since Java 11 there is a repeat method in String
Tommy Guinness
Level 15 , Newcastle West, Ireland
8 October 2019, 20:37
Hi lads whats wrong with code ?