首页 > 编程语言 > 详细

java中String,int,Integer,char、double类型转换

时间:2016-09-12 20:20:32      阅读:136      评论:0      收藏:0      [点我收藏+]

转自 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类型的时候 需要用到。

 

java中String,int,Integer,char、double类型转换

原文:http://www.cnblogs.com/kangyu222/p/5866025.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!