Easy understand.

```
public int reverse(int x) {
int value=0;
while(x!=0){
int mod = x%10;
if((value<Integer.MAX_VALUE/10 && value>Integer.MIN_VALUE/10) ||
(value==Integer.MAX_VALUE/10&&mod<=7)
|| (value==Integer.MIN_VALUE/10&&mod<=8))
value=value*10+mod;
else x=value=0;
x=(x/10);
}
return value;
}
```