내가 작성한 기본 프로그램에 관해서는 racecar와 같은 단어가 회문인지 아닌지에 대해 질문했습니다.문자열이 문자열인지 여부를 확인 String.equals()
문자열을 뒤집는 나의 모든 방법은 문장 부호를 제거하지만 문장 부호인지 아닌지는 판별하지 않습니다. 뭔가가 회문이
public boolean isPalindrome(String string)
{
return string.equals(reverseString(string));
}
해야하는 경우
/**
* 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)));
}
은 숙제와 같은 냄새가납니다. – jldupont
reverseString은 어디에 정의합니까? – EmFi
그리고 질문은 ...? – sinuhepop