public static String getString ( String sample , int length , int repeats ) {
  StringBuilder sb = new StringBuilder ( sample ) ;
  int mainPos = 0 ;
  int samplePos = 0 ;
  for ( int i = 0 ;
  i < repeats ;
  i ++ ) {
    for ( int j = 0 ;
    j < length ;
    j ++ ) {
      if ( ( mainPos + samplePos ) >= sb . length ( ) ) {
        sb . append ( sample . charAt ( samplePos ) ) ;
      }
      if ( sb . charAt ( mainPos + samplePos ) != sample . charAt ( samplePos ) ) {
        i -- ;
        break ;
      }
      samplePos ++ ;
    }
    mainPos ++ ;
    samplePos = 0 ;
  }
  return sb . toString ( ) ;
}

public static String getString ( String sample , int length , int repeats ) { StringBuilder sb = new StringBuilder ( sample ) ; int mainPos = 0 ; int samplePos = 0 ; for ( int i = 0 ; i < repeats ; i ++ ) { for ( int j = 0 ; j < length ; j ++ ) { if ( ( mainPos + samplePos ) >= sb . length ( ) ) { sb . append ( sample . charAt ( samplePos ) ) ; } if ( sb . charAt ( mainPos + samplePos ) != sample . charAt ( samplePos ) ) { i -- ; break ; } samplePos ++ ; } mainPos ++ ; samplePos = 0 ; } return sb . toString ( ) ; }
(method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (block (expression_statement (update_expression (identifier))) (break_statement))) (expression_statement (update_expression (identifier))))) (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))