public class ArrayParser{
public static void main(String[] args){ double[][] d; String s = "1,2;3,4,5;6,7,8"; String[] sFirst = s.split(";"); //第一次按分号拆分; d = new double[sFirst.length][]; for(int i=0;i<sFirst.length;i++){ /* System.out.println(sFirst[i]);*/ String[] sSecond = sFirst[i].split(","); //在第一个拆分的基础上,再按逗号分割; d[i] = new double[sSecond.length]; for(int j=0;j<sSecond.length;j++){ /* System.out.println(sSecond[j]);*/ d[i][j] = Double.parseDouble(sSecond[j]); //把值转换为double类型赋值给数组d; } } for(int i=0;i<d.length;i++){ for(int j=0;j<d[i].length;j++){ System.out.print(d[i][j]+ " "); } System.out.println(); } }}