数字类型和字符串类型的相互转换

各种数字类型转换成字符串型: 
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 ); 


猜你喜欢

转载自blog.csdn.net/yzwty/article/details/52735969