问题
I am self studying java, i am on while loops already, I have an exercise here regarding a palindrome. what's a palindrome? how will code it? any ideas? or pseudocode for it? I am really confused here
NOT a HOMEWORK
回答1:
Since its not homework, it shouldn't matter how you implement it.
public static <ToStringable> boolean isPalindrome(ToStringable stringable) {
String text = stringable.toString();
return text.equals(new StringBuilder(text).reverse().toString());
}
回答2:
A palindrome is a sequence that reads the same backwards as forwards, like "kayak" or 12321.
See here: http://en.wikipedia.org/wiki/Palindrome
EDIT: there are also lots of questions about palindromes on stackoverflow already. Browse through them and come back if you have more specific questions:
https://stackoverflow.com/questions/tagged/palindrome
回答3:
Palindrome is a sequence such that reversing the sequence gives you the same sequence. E.g. MAM
来源:https://stackoverflow.com/questions/6068767/palindrome-in-java-with-numbers