2017-09-23 10:01:46 +02:00
|
|
|
public static String repeat(String str, int times) {
|
|
|
|
|
StringBuilder sb = new StringBuilder(str.length() * times);
|
|
|
|
|
for (int i = 0; i < times; i++)
|
|
|
|
|
sb.append(str);
|
|
|
|
|
return sb.toString();
|
2013-04-10 23:57:08 -07:00
|
|
|
}
|
|
|
|
|
|
2017-09-23 10:01:46 +02:00
|
|
|
public static void main(String[] args) {
|
|
|
|
|
System.out.println(repeat("ha", 5));
|
2013-04-10 23:57:08 -07:00
|
|
|
}
|