私は現在、高校で取っているクラスのために Java で回文テスターを書いています。私は先生に助けを求めましたが、彼も混乱しています。私は、stackoverflow のコミュニティが私を助けてくれることを望んでいました。ありがとうございました。
public class Palindrome
{
private String sentence;
public Palindrome(String s)
{
sentence = s;
}
public boolean isPalindrome()
{
if(sentence.length() <= 1)
{
return true;
}
if(sentence.charAt(0) == sentence.charAt(sentence.length()-1))
{
sentence = sentence.substring(1, sentence.length()-1);
isPalindrome();
}
else
return false;
}
}