public static String repeatString(String source,int repeat){
  if (repeat < 0) {
    throw new IllegalArgumentException("Cannot repeat " + repeat + " times.");
  }
  if (repeat == 0 || source == null || source.length() == 0) {
    return "";
  }
  StringBuffer buffer=new StringBuffer();
  for (int i=0; i < repeat; i++) {
    buffer.append(source);
  }
  return buffer.toString();
}

public static String repeatString ( String source , int repeat ) { if ( repeat < 0 ) { throw new IllegalArgumentException ( "Cannot repeat " + repeat + " times." ) ; } if ( repeat == 0 || source == null || source . length ( ) == 0 ) { return "" ; } StringBuffer buffer = new StringBuffer ( ) ; for ( int i = 0 ; i < repeat ; i ++ ) { buffer . append ( source ) ; } return buffer . toString ( ) ; }
repeat the string source repeat times . if repeats = = 0 then empty string is returned if source is null , then empty string is returned
