I want to duplicate a String by a given number separated by ,
. For example:
int i=3;
String word = "a";
String result = String.duplicate(word, ',', i);
// result is: "a,a,a"
I know there is something like that in Ruby but I'm looking in Java. I wrote some code with a loop and then I removed the last char (which is the ,
). I wondered if there is a build-in function.
I did write my own function, I just wanted to know if there is build-in for that..