Anonymous user
Repeat a string: Difference between revisions
→{{header|Java}}
Line 18:
There's no function or operator to do this in Java, so you have to do it yourself.
<lang java5>public static String repeat(String str, int times){
StringBuilder ret = new StringBuilder(
for(int i =
return ret.toString();
}
Line 26:
System.out.println(repeat("ha", 5));
}</lang>
=={{header|JavaScript}}==
This solution creates an array of n+1 null elements, then joins them using the target string as the delimiter
|