public static boolean check ( String st ) {
  Stack < Character > stck = new Stack < Character > ( ) ;
  for ( char c : st . toCharArray ( ) ) {
    if ( c == '(' ) {
      stck . push ( ')' ) ;
    }
    else if ( c == '[' ) {
      stck . push ( ']' ) ;
    }
    else if ( stck . isEmpty ( ) || c != stck . pop ( ) ) {
      return false ;
    }
  }
  return stck . isEmpty ( ) ;
}

public static boolean check ( String st ) { Stack < Character > stck = new Stack < Character > ( ) ; for ( char c : st . toCharArray ( ) ) { if ( c == ' ( ' ) { stck . push ( ' ) ' ) ; } else if ( c == ' [ ' ) { stck . push ( ' ] ' ) ; } else if ( stck . isEmpty ( ) || c != stck . pop ( ) ) { return false ; } } return stck . isEmpty ( ) ; }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (character_literal))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (character_literal))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) consequence: (block (return_statement (false)))))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))