私が書いている基本的なプログラムについて、レースカーなどの単語が回文であるかどうかについて質問がありました。
文字列を逆にして句読点を削除する私のすべての方法は機能しますが、それが回文であるかどうかを判断する方法はそうではありません。
/**
* Determines if a series of letters makes a palinedrome
*
* @param str All punctuation and spaces have been removed
* before this method is called.
* @return true if phrase is a palindrome,
* false otherwise.
*/
public boolean isPalindrome(String str)
{
String d = reverseString (str);
return( str.equals (reverseString (str) ) );
}