链接:Here
class Solution {
public int reverse(int x) {
boolean isN = false;
if(x < 0)
{
isN = true;
x = -x;
}
long sum = 0;
while(x!=0){
sum = sum * 10 + x%10;
x = x / 10;
}
if(isN){
sum = -sum;
}
if (sum >Integer.MAX_VALUE || sum < Integer.MIN_VALUE)
return 0;
return new Long(sum).intValue();
}
}