public static String multiply ( CharSequence self , Number factor ) { String s = self . toString ( ) ; int size = factor . intValue ( ) ; if ( size == 0 ) return "" ; else if ( size < 0 ) { throw new IllegalArgumentException ( "multiply() should be called with a number of 0 or greater not: " + size ) ; } StringBuilder answer = new StringBuilder ( s ) ; for ( int i = 1 ; i < size ; i ++ ) { answer . append ( s ) ; } return answer . toString ( ) ; }
Repeat a CharSequence a certain number of times .