static int maxLengthNonPalinSubstring ( String str ) {
  int n = str . length ( ) ;
  char ch = str . charAt ( 0 ) ;
  int i = 1 ;
  for ( i = 1 ;
  i < n ;
  i ++ ) if ( str . charAt ( i ) != ch ) break ;
  if ( i == n ) return 0 ;
  if ( isPalindrome ( str ) ) return n - 1 ;
  return n ;
}

static int maxLengthNonPalinSubstring ( String str ) { int n = str . length ( ) ; char ch = str . charAt ( 0 ) ; int i = 1 ; for ( i = 1 ; i < n ; i ++ ) if ( str . charAt ( i ) != ch ) break ; if ( i == n ) return 0 ; if ( isPalindrome ( str ) ) return n - 1 ; return n ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (identifier))) consequence: (break_statement))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier)))) consequence: (return_statement (binary_expression left: (identifier) right: (decimal_integer_literal)))) (return_statement (identifier))))