static String PrefixSuffixPalindrome ( String str ) {
  int n = str . length ( ) , len = 0 ;
  for ( int i = 0 ;
  i < n / 2 ;
  i ++ ) {
    if ( str . charAt ( i ) != str . charAt ( n - i - 1 ) ) {
      len = i ;
      break ;
    }
  }
  String prefix = "" , suffix = "" ;
  String midPal = "" ;
  prefix = str . substring ( 0 , len ) ;
  suffix = str . substring ( n - len ) ;
  str = str . substring ( len , ( n - 2 * len ) + len ) ;
  for ( int i = 1 ;
  i <= str . length ( ) ;
  i ++ ) {
    String y = str . substring ( 0 , i ) ;
    if ( isPalindrome ( y ) ) {
      if ( midPal . length ( ) < y . length ( ) ) {
        midPal = y ;
      }
    }
  }
  for ( int i = 1 ;
  i <= str . length ( ) ;
  i ++ ) {
    String y = str . substring ( str . length ( ) - i ) ;
    if ( isPalindrome ( y ) ) {
      if ( midPal . length ( ) < y . length ( ) ) {
        midPal = y ;
      }
    }
  }
  String answer = prefix + midPal + suffix ;
  return answer ;
}

static String PrefixSuffixPalindrome ( String str ) { int n = str . length ( ) , len = 0 ; for ( int i = 0 ; i < n / 2 ; i ++ ) { if ( str . charAt ( i ) != str . charAt ( n - i - 1 ) ) { len = i ; break ; } } String prefix = " " , suffix = " " ; String midPal = " " ; prefix = str . substring ( 0 , len ) ; suffix = str . substring ( n - len ) ; str = str . substring ( len , ( n - 2 * len ) + len ) ; for ( int i = 1 ; i <= str . length ( ) ; i ++ ) { String y = str . substring ( 0 , i ) ; if ( isPalindrome ( y ) ) { if ( midPal . length ( ) < y . length ( ) ) { midPal = y ; } } } for ( int i = 1 ; i <= str . length ( ) ; i ++ ) { String y = str . substring ( str . length ( ) - i ) ; if ( isPalindrome ( y ) ) { if ( midPal . length ( ) < y . length ( ) ) { midPal = y ; } } } String answer = prefix + midPal + suffix ; return answer ; }
(method_declaration (modifiers) type: (type_identifier) 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))) 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: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (break_statement))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal)) declarator: (variable_declarator name: (identifier) value: (string_literal))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))) right: (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))))) (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (identifier)))))) (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (return_statement (identifier))))