```
public int reverse(int x) {
if ((x < 10 && x >= 0) || (x > -10 && x < 0)) return x;
String num = Integer.toString(x);
String newNum = "";
boolean isNeg = false;
if (x < 0) {
isNeg = true;
num = num.substring(1);
}
for (int i = num.length()-1; i >= 0; i--) {
newNum = newNum + num.charAt(i);
}
if (isNeg) newNum = "-" + newNum;
return Integer.parseInt(newNum);
}
```