leetcodeo7---reverse

来源:互联网 发布:mac os stm8 编辑:程序博客网 时间:2024/06/05 22:41
public  static int reverse(int x){
char [] numArry=null;
String numStr="";
if(x==0){
return x;
}
else if(x>0){
numArry=(x+"").toCharArray();
}
else{
numStr+="-";

numArry=(x+"").substring(1).toCharArray();

}
for(int i=numArry.length-1;i>=0;i--){
numStr+=numArry[i];
}
return Integer.valueOf(numStr);
}


}
0 0