static boolean divideArray ( int arr [ ] , int n ) {
  int sum = 0 ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) sum += arr [ i ] ;
  int sum_so_far = 0 ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    if ( 2 * sum_so_far + arr [ i ] == sum ) {
      System . out . print ( "The array can be divided into " + "two subarrays with equal sum\nThe" + " two subarrays are - " ) ;
      printSubArray ( arr , 0 , i - 1 ) ;
      printSubArray ( arr , i + 1 , n - 1 ) ;
      return true ;
    }
    sum_so_far += arr [ i ] ;
  }
  System . out . println ( "The array cannot be divided into two " + "subarrays with equal sum" ) ;
  return false ;
}

static boolean divideArray ( int arr [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; int sum_so_far = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( 2 * sum_so_far + arr [ i ] == sum ) { System . out . print ( " The ▁ array ▁ can ▁ be ▁ divided ▁ into ▁ " + " two ▁ subarrays ▁ with ▁ equal ▁ sum \n The " + " ▁ two ▁ subarrays ▁ are ▁ - ▁ " ) ; printSubArray ( arr , 0 , i - 1 ) ; printSubArray ( arr , i + 1 , n - 1 ) ; return true ; } sum_so_far += arr [ i ] ; } System . out . println ( " The ▁ array ▁ cannot ▁ be ▁ divided ▁ into ▁ two ▁ " + " subarrays ▁ with ▁ equal ▁ sum " ) ; return false ; }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (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: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))) (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 (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (array_access array: (identifier) index: (identifier))) right: (identifier))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (string_literal) right: (string_literal)) right: (string_literal))))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal))))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (decimal_integer_literal))))) (return_statement (true)))) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (string_literal))))) (return_statement (false))))