java 怎么把一个String型数组 转成Double型数组

2024-11-18 17:31:28
推荐回答(5个)
回答1:

把你的String型数组遍历一次,然后通过Double.parseDouble把String型数组每个值转换一次。然后赋值给Double型数组中值

回答2:

String[] str = new String[] { "1.0", "2.0", "3.0" };
double[] dou = new double[3];
for (int i = 0, len = str.length; i < len; i++) {
dou[i] = Double.valueOf(str[i]);
}

回答3:

public static void main(String[] args) {
String[] strs={"111.1","222.2","33.33"};
Double[] ds=new Double[strs.length];
for(int i=0;i ds[i]=Double.valueOf(strs[i]);
}
//打印double型数组
for(double d:ds){
System.out.println(d);
}
}

回答4:

强转就可以了。
String str = "12.3";
double dot = (double)str;

回答5:

LZ你听过这么转的吗?我好像没听过