实现代码如下:
package test;
public class Test5 {
public static int reverse(int x) {
long result = 0;
while(x!=0){
int n = x%10;
result = result*10+n;
x=x/10;
}
if( result > Integer.MAX_VALUE || result < Integer.MIN_VALUE)
return 0;
return (int)result;
}
public static void main(String[] args) {
int x=153423646;
int y = Test5.reverse(x);
System.out.println(y);
}
}
如果你有更好的方法,请加QQ群691761026一起交流