我得到了ArrayIndexOutOfBoundException
这里。我错过了什么?
我的代码如下:
public class Exercise {
public static double[] strfloat(String str){
double[] f = new double[] {};
String[] st = new String[] {};
st= str.split(" ");
for(int i = 0; i < st.length; i++){
System.out.println(st[i]);
f[i] = Double.parseDouble(st[i]);
System.out.println(f[i]);
}
return f;
}
public static void main(String[] args) {
String str = "1.99999996e-002 7.49999983e-003 0. 1.75000001e-002 9.99999978e-003";
double[] retstr = strfloat(str);
for(int i = 0; i < retstr.length; i++){
System.out.println(retstr[i] + " ");
}
}