repeatStr static method

String repeatStr(
  1. String r,
  2. int reps
)

Implementation

static String repeatStr(String r, int reps) {
  // this if detection might be overcomplicated
  if (reps == 0) {
    return "";
  }
  if (reps == 1) {
    return r;
  }
  StringBuffer buffer = StringBuffer();
  for (int i = 0; i < reps; i++) {
    buffer.write(r);
  }
  return buffer.toString();
}