java数字转换成字符串
生活随笔
收集整理的這篇文章主要介紹了
java数字转换成字符串
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
各種數(shù)字類型轉(zhuǎn)換成字符串型:?
String s = String.valueOf( value); // 其中 value 為任意一種數(shù)字類型。?
字符串型轉(zhuǎn)換成各種數(shù)字類型:?
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 );?
數(shù)字類型與數(shù)字類對象之間的轉(zhuǎn)換:?
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;?
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();
String s = String.valueOf( value); // 其中 value 為任意一種數(shù)字類型。?
字符串型轉(zhuǎn)換成各種數(shù)字類型:?
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 );?
數(shù)字類型與數(shù)字類對象之間的轉(zhuǎn)換:?
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;?
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();
總結(jié)
以上是生活随笔為你收集整理的java数字转换成字符串的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 成都大熊猫繁育研究基地停车攻略
- 下一篇: java 设计作业——简单计算器