double处理

String s = "1,3;2,3,4;5";

String[] split = s.split(";");
double[][] d;
d = new double[split.length][];
for (int i = 0; i < split.length; i++) {
String[] split1 = split[i].split(",");
double[] doubles = new double[split1.length];
for (int j = 0; j < split1.length; j++) {
doubles[j] = Double.parseDouble(split1[j]);
}
d[i] = doubles;
}


for (double[] doubles : d) {
for (double aDouble : doubles) {
System.out.print(aDouble+" ");
}
System.out.println();
}
posted @ 2019-11-11 12:13  雷神约  阅读(229)  评论(0编辑  收藏  举报