Repeat String N Times with Java

On March 29, 2013, in Java, Programming, by LuCuS

Repeat a string N number of times using Java.

String string_to_repeat = "XO";
int number_of_times_to_repeat = 5;
String repeated_string = StringUtils.repeat(string_to_repeat, number_of_times_to_repeat);
System.out.println(repeated_string);

Output:
XOXOXOXOXO

Thank you for your interest in my site. If you find the information provided on this site useful, please consider making a donation to help continue development!

PayPal will open in a new tab.
$2.00
$5.00
Other

Related Posts

Tagged with:  

Leave a Reply