I want a primitive that can duplicate a string. It takes the string and the number of duplication as input and generate the output. The number of duplication includes 0. Meaning it will generate empty string. I cannot think of a shorter way to do it besides the one below. The one below uses "." as an example string.
String res = "";
for(int i = 0; i < dup; i++) {
res = res + ".";
}
return res;
Anyone has a neater solution?