public class reveserInt {
public static void main(String[] args) {
int reverse = reverse(-99);
System.out.println(reverse);
}
public static int reverse(int num) {
String str = "";
int temp;
if (num < 0) {
str = "-";
}
temp = Math.abs(num);
while (temp != 0) {
int i = temp % 10;
temp /= 10;
str += (i + "");
}
int result = 0;
try {
result = Integer.parseInt(str);
} catch (NumberFormatException e) {
e.printStackTrace();
return 0;
}
if (result > Math.pow(2, 31) - 1 || result < Math.pow(-2, 31)) {
return 0;
}
return result;
}
}