java 数据类型转换

各种数字类型转换成字符串型:
String resultstring = String.valueOf( anytypeofdata);

 

字符串型转换成数字类型:
byte b = Byte.parseByte( String sourcestring );
short t = Short.parseShort( String sourcestring );
int i = Integer.parseInt( String sourcestring );
long l = Long.parseLong( String sourcestring );
float f = Float.parseFloat( String sourcestring );
double d = Double.parseDouble( String sourcestring );

 

数字类型与数字类对象之间相互转换:
Byte bo = new Byte( byte b );
byte b = bo.byteValue();
 
Short to = new Short( short t );
short t = to.shortValue();

 

Integer io = new Integer( int i );
int i = io.intValue();

 

Long lo = new Long( long l );
long l = lo.longValue();

 

Float fo = new Float( float f );
float f = fo.floatValue();

 

Double dObj = new Double( double d );
double d = dObj.doubleValue();

转载于:https://www.cnblogs.com/super-yc/archive/2006/10/14/529222.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值