String字符串转化为数字:
转换为浮点型:
使用Double或者Float的parseDouble或者parseFloat方法进行转换
String s = "123.456 ";
double d = Double.parseDouble(s);
float f = Float.parseFloat(s);
转换为整型:
使用Integer的parseInt方法进行转换。
String s = "123"
int i = Integer.parseInt(s);
数字转化为字符串:使用String对象的valueOf()方法
int a = 123;
String s = String.valueOf(a);
则输出为:“123”