1.字符串转化为二维Double数组
2.代码:
package Test; public class TestDouble { public static void main(String[] args) { String str = "1,2;3,4,5;6,7,8,9";
String [] strArr = str.split(";");
String [] strArr2;
int len = strArr.length;
int len2;
Double [][] doubles = new Double[len][];
//doubles[0] = new Double[2];
//doubles[0][1] = 0.22;
//System.out.println(doubles[0][1]); for(int i = 0 ; i < len ; i++){
strArr2 = strArr[i].split(",");
len2 = strArr2.length;
doubles[i] = new Double[len2];
for(int j = 0 ; j < len2 ; j++){
//System.out.println(i+"--"+j+"--"+Double.valueOf(strArr2[j]));
doubles[i][j] = Double.valueOf(strArr2[j]);
}
} for(Double [] d : doubles){
for(Double d2 : d){
System.out.print(d2+"\t");
}
System.out.println();
}
}
}
3.运行结果: