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(9)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Brandon LeirerLevel 7 , Keller
12 June, 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 KorolLevel 14 , Coral Springs
10 April, 04:26
The wording of this task is misleading.
JaseyLevel 9 , Chester
11 January, 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 blaustromLevel 18 , Luzern
13 December 2019, 19:41
Actually since Java 11 there is a repeat method in String
Tommy GuinnessLevel 15 , Newcastle West
8 October 2019, 20:37
Hi lads whats wrong with code ?
Jyoti MauryaLevel 8 , Maihar
29 May 2019, 11:57
woah! first I thought I'll have to do it with typecasting but then I checked the dicuss section and understood the question properly. It wasnt that difficult. :)
amousLevel 10
7 September 2018, 05:12
what do we have to do in this task ?? will we get the string or do we have to divide the strings into substrings and compare each of them to see which one is being repeated ?
RomanLevel 41
7 September 2018, 05:54
You have to make the StringHelper class, which will have 2 static methods: String multiply(String s, int count) - returns a string that has been repeated count times. String multiply(String s) - returns a string that has been repeated 5 times. For example: multiply("Amigo") returns string "AmigoAmigoAmigoAmigoAmigo" multiply("Amigo", 3) returns string "AmigoAmigoAmigo"
amousLevel 10
7 September 2018, 18:53
thank you. i thought we had to check for repetition :|