public static void calc8 ( char [ ] [ ] cell , int h , int w ) {
  if ( cell [ h ] [ w ] == '#' ) System . out . print ( '#' ) ;
  else {
    int [ ] hs = new int [ ] {
      h - 1 , h , h + 1 };
      int [ ] ws = new int [ ] {
        w - 1 , w , w + 1 };
        int sum = 0 ;
        for ( int nh : hs ) {
          for ( int nw : ws ) {
            if ( nh < cell . length && nh >= 0 && nw >= 0 && nw < cell [ 0 ] . length ) {
              if ( cell [ nh ] [ nw ] == '#' ) sum ++ ;
            }
          }
        }
        System . out . print ( sum ) ;
      }
      if ( w == cell [ 0 ] . length - 1 ) System . out . println ( "" ) ;
    }
    
public static void calc8 ( char [ ] [ ] cell , int h , int w ) { if ( cell [ h ] [ w ] == ' # ' ) System . out . print ( ' # ' ) ; else { int [ ] hs = new int [ ] { h - 1 , h , h + 1 } ; int [ ] ws = new int [ ] { w - 1 , w , w + 1 } ; int sum = 0 ; for ( int nh : hs ) { for ( int nw : ws ) { if ( nh < cell . length && nh >= 0 && nw >= 0 && nw < cell [ 0 ] . length ) { if ( cell [ nh ] [ nw ] == ' # ' ) sum ++ ; } } } System . out . print ( sum ) ; } if ( w == cell [ 0 ] . length - 1 ) System . out . println ( " " ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (character_literal))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (character_literal)))) alternative: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions) value: (array_initializer (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions) value: (array_initializer (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (identifier) right: (field_access object: (array_access array: (identifier) index: (decimal_integer_literal)) field: (identifier))))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (character_literal))) consequence: (expression_statement (update_expression (identifier)))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (field_access object: (array_access array: (identifier) index: (decimal_integer_literal)) field: (identifier)) right: (decimal_integer_literal)))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))))