static String findString ( String str , int n ) {
  StringBuilder sb = new StringBuilder ( "" ) ;
  int startStr = nextNonDigit ( str , 0 ) ;
  while ( startStr != - 1 ) {
    int endStr = startStr ;
    while ( ( endStr + 1 ) < n && ! isDigit ( str . charAt ( endStr + 1 ) ) ) {
      endStr ++ ;
    }
    int startNum = endStr + 1 ;
    if ( startNum == - 1 ) break ;
    int endNum = startNum ;
    while ( ( endNum + 1 ) < n && isDigit ( str . charAt ( endNum + 1 ) ) ) {
      endNum ++ ;
    }
    int num = Integer . parseInt ( str . substring ( startNum , endNum + 1 ) ) ;
    appendRepeated ( sb , str . substring ( startStr , endStr + 1 ) , num ) ;
    startStr = nextNonDigit ( str , endStr + 1 ) ;
  }
  return sb . toString ( ) ;
}

static String findString ( String str , int n ) { StringBuilder sb = new StringBuilder ( " " ) ; int startStr = nextNonDigit ( str , 0 ) ; while ( startStr != - 1 ) { int endStr = startStr ; while ( ( endStr + 1 ) < n && ! isDigit ( str . charAt ( endStr + 1 ) ) ) { endStr ++ ; } int startNum = endStr + 1 ; if ( startNum == - 1 ) break ; int endNum = startNum ; while ( ( endNum + 1 ) < n && isDigit ( str . charAt ( endNum + 1 ) ) ) { endNum ++ ; } int num = Integer . parseInt ( str . substring ( startNum , endNum + 1 ) ) ; appendRepeated ( sb , str . substring ( startStr , endStr + 1 ) , num ) ; startStr = nextNonDigit ( str , endStr + 1 ) ; } 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))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (identifier)) right: (unary_expression operand: (method_invocation name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal))))))))) body: (block (expression_statement (update_expression (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (break_statement)) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (identifier)) right: (method_invocation name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) body: (block (expression_statement (update_expression (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))) (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))