-2

Possible Duplicate:
creating a recursive method for Palindrome In java

This is my code that I have written.

public boolean checkPalindrome(string word){

for(int i=0 ; i < word.length()/2;i++)
{
  if(word.charAt(i) ! = word.charAt(word.length()-1-i))

      return false;
}

return true;
}

The purpose of this method to check if a given string is a palindrome.

Community
  • 1
  • 1
user1268088
  • 77
  • 1
  • 2
  • 3

2 Answers2

1

Hint: change function signature to boolean checkPalindrome(String word, int index);

IProblemFactory
  • 9,551
  • 8
  • 50
  • 66
1

If you had a function that could check whether a sub-string of your word is a palindrome, would that help you check whether your main word was also a palindrome?