public static final String copyString(String str,int copies){
  String result="";
  String powerOf2Copies=str;
  int remaining=copies;
  while (remaining > 0) {
    if (remaining % 2 != 0) {
      result=result + powerOf2Copies;
    }
    remaining=remaining / 2;
    if (remaining != 0) {
      powerOf2Copies=powerOf2Copies + powerOf2Copies;
    }
  }
  return result;
}

public static final String copyString ( String str , int copies ) { String result = "" ; String powerOf2Copies = str ; int remaining = copies ; while ( remaining > 0 ) { if ( remaining % 2 != 0 ) { result = result + powerOf2Copies ; } remaining = remaining / 2 ; if ( remaining != 0 ) { powerOf2Copies = powerOf2Copies + powerOf2Copies ; } } return result ; }
returns the result of concatenating ' copies ' copies of string str , or the empty string if copies < 0 .
