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();
}

猜你喜欢

转载自www.cnblogs.com/leigepython/p/11834054.html