public static void main ( String args [ ] ) {
  int [ ] arr = {
    1 , - 3 , 5 , 6 , - 3 , 6 , 7 , - 4 , 9 , 10 };
    int n = arr . length ;
    printArray ( arr , n ) ;
    for ( int i = 0 ;
    i < n ;
    i ++ ) {
      if ( arr [ i ] >= 0 && i % 2 == 1 ) {
        for ( int j = i + 1 ;
        j < n ;
        j ++ ) {
          if ( arr [ j ] < 0 && j % 2 == 0 ) {
            swap ( arr , i , j ) ;
            break ;
          }
        }
      }
      else if ( arr [ i ] < 0 && i % 2 == 0 ) {
        for ( int j = i + 1 ;
        j < n ;
        j ++ ) {
          if ( arr [ j ] >= 0 && j % 2 == 1 ) {
            swap ( arr , i , j ) ;
            break ;
          }
        }
      }
    }
    printArray ( arr , n ) ;
  }
  
public static void main ( String args [ ] ) { int [ ] arr = { 1 , - 3 , 5 , 6 , - 3 , 6 , 7 , - 4 , 9 , 10 } ; int n = arr . length ; printArray ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= 0 && i % 2 == 1 ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] < 0 && j % 2 == 0 ) { swap ( arr , i , j ) ; break ; } } } else if ( arr [ i ] < 0 && i % 2 == 0 ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] >= 0 && j % 2 == 1 ) { swap ( arr , i , j ) ; break ; } } } } printArray ( arr , n ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_initializer (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal) (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal) (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) (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: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) consequence: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (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: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier)))) (break_statement)))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) consequence: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (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: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier)))) (break_statement)))))))))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))))