public static String repeat(String sourceString,int factor){
  if (factor < 1) {
    return "";
  }
  if (factor == 1) {
    return sourceString;
  }
  StringBuilder sb=new StringBuilder(factor * sourceString.length());
  while (factor > 0) {
    sb.append(sourceString);
    factor--;
  }
  return sb.toString();
}

public static String repeat ( String sourceString , int factor ) { if ( factor < 1 ) { return "" ; } if ( factor == 1 ) { return sourceString ; } StringBuilder sb = new StringBuilder ( factor * sourceString . length ( ) ) ; while ( factor > 0 ) { sb . append ( sourceString ) ; factor -- ; } return sb . toString ( ) ; }
returns sourcestring concatenated together ' factor ' times .
