编写一个函数,判断某数字是否是回文数字。
public class PalindromeNumber { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); System.out.println("请输入数字:"); String strNum = scan.next(); boolean result = isPalindrome(strNum); System.out.println(result); } public static Boolean isPalindrome(String str){ boolean result=false; for(int i=0; i<str.length()/2;i++){ if(str.charAt(i) == str.charAt(str.length()-1-i)){ result=true; }else{ return result; } } return result; }
以上就是java怎么判断一个数是不是回文数的详细内容,更多请关注大盘站其它相关文章!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。