public static void reverse(int number) {
int temp = number;
String s="";
//计算该数多少位
int count = 0;
while (number != 0) {
number = number / 10;
count++;
}
//恢复
number = temp;
int[] arr = new int[count];
int index = 0;
if (number<0){
number*=-1;
s+="-";
}
while (number != 0) {
//依次获取低位数字
int a = number % 10;
number = number / 10;
arr[index] = a;
index++;
}
for (int i = 0; i < arr.length; i++) {
s+=arr[i];
}
System.out.println(s);
}
04-11
2498
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)