Palindrome in Java with NUmbers [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this questionI 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
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());
}
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
Palindrome is a sequence such that reversing the sequence gives you the same sequence. E.g. MAM
精彩评论