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.
StringHelper class
- 5
Locked
Comments (14)
- Popular
- New
- Old
You must be signed in to leave a comment
Xavi MartinExpert
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?
+1
Chloe
21 October 2021, 06:48
you can use a for loop and "result+=s;"
0
Aron
8 July 2021, 21:19
use a for loop to append onto the result variable
0
Sinisa
25 February 2021, 14:13
Pure confusion.
+2
monipuff
10 August 2020, 12:18
for loop came in handy :)
0
Brandon Leirer
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; ?
0
Vladyslav Korol
10 April 2020, 04:26
The wording of this task is misleading.
+3
Jasey
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.
0
oli blaustrom
13 December 2019, 19:41
Actually since Java 11 there is a repeat method in String
0
Tommy Guinness
8 October 2019, 20:37
Hi lads whats wrong with code ?
0