public class Test{
public static void main(String[] args){
boolean b = isHuiWenShu(15651);
}
//判断一个数是否是回文数
private static boolean isHuiWenShu(int n){
int m = n;
int s = 0;
while(m > 0){
s = s*10 + m%10;
m /=10;
}
if(s == n){
System.out.println("是回文数");
return true;
}
System.out.println("不是回文数");
return false;
}
}
转载于:https://blog.51cto.com/12257915/1878071