Palindrome in Java with NUmbers [closed]

ぃ、小莉子 提交于 2019-12-13 22:40:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!