```
public class Solution {
public boolean isPalindrome(int x) {
if (x < 0) {
return false;
}
double rev = 0;
int tmp = x;
while(tmp > 0) {
rev = (double)(tmp%10) + rev*10;
tmp = tmp/10;
}
int tail;
while(x > 0) {
tmp = x%10;
tail = (int)rev%10;
if (tail != tmp) {
return false;
}
x /= 10;
rev = (rev-tail)/10;
}
return true;
}
}
```