ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 类型转换

类型转换

原创 Linux操作系统 作者:huaspace 时间:2007-12-13 12:38:28 0 删除 编辑

各种数字类型转换成字符串型--JAVA
各种数字类型转换成字符串型:

String s = String.valueOf( value); // 其中 value 为任意一种数字类型。

字符串型转换成各种数字类型:

String s = "169";
byte b = Byte.parseByte( s );
short t = Short.parseShort( s );
int i = Integer.parseInt( s );
long l = Long.parseLong( s );
Float f = Float.parseFloat( s );
Double d = Double.parseDouble( s );

数字类型与数字类对象之间的转换:

byte b = 169;
Byte bo = new Byte( b );
b = bo.byteValue();

short t = 169;
Short to = new Short( t );
t = to.shortValue();

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

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

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

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

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12389842/viewspace-516/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 释放数据库资源
下一篇: 网线制作
请登录后发表评论 登录
全部评论

注册时间:2007-12-13

  • 博文量
    7
  • 访问量
    4673