转自 http://blog.csdn.net/zhang103886108/article/details/42917693

1、如何将字串 String 转换成整数 int? 
int i = Integer.valueOf(my_str).intValue();

int i=Integer.parseInt(str);

2、如何将字串 String 转换成Integer ?
Integer integer=Integer.valueOf(str);

 

3、如何将整数 int 转换成字串 String ? 
1.) String s = String.valueOf(i);
2.) String s = Integer.toString(i); 
3.) String s = "" + i; 

  4、如何将整数 int 转换成Integer ? 
Integer integer=new Integer(i);

6、如何将Integer 转换成 int ? 
int num=Integer.intValue();

12、String转double

String s;

double ss=Double.parseDouble(s);

 

注:parseDouble parseInt 返回的是double。

 

Double 和 Integer 是double和int的封装类 当需要转换成string类型的时候 需要用到。

 

相关文章:

  • 2022-12-23
  • 2021-12-04
  • 2021-09-06
  • 2021-08-28
  • 2022-12-23
  • 2021-10-31
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2021-05-22
  • 2022-12-23
  • 2021-08-01
相关资源
相似解决方案