假设这个数是变量a,那么:String s1 = a+"";//转成字符串先String s2 = "";for(int i=s1.length()-1;i>=0;i--){//把s1反序,用s2接收s2 += s1.substring(i,i+1);}if(s1==s2){System.out.print(a+"是回文数");}else{System.out.print(a+"不是回文数");}