学习笔记:
转换为浮点型:
使用Double或者Float的parseDouble或者parseFloat方法进行转换
String s = "123.456 "; //要确保字符串为一个数值,否则会出异常
double d = Double.parseDouble(s);
float f = Float.parseFloat(s);
转换为整型:
使用Integer的parseInt方法进行转换。
int i = Integer.parseInt([String]);//[String]待转换的字符串