Turn string values into 2d array of type double

前端 未结 5 884
失恋的感觉
失恋的感觉 2021-01-20 00:01

I have a string:

String stringProfile = \"0,4.28 10,4.93 20,3.75\";

I am trying to turn it into an array like as follows:

d         


        
5条回答
  •  盖世英雄少女心
    2021-01-20 00:45

    if you split with " " you get an array of one dimension, then you can split again and get a multidimensional array like you want:

    String arrayS = "0,4.28 10,4.93 20,3.75";
    String [] a = arrayS.spit(" ");
    double [][] arrayD;
    for(String j: a){
        arrayD.append(j.split(","));
    }
    //then print your array here
    

提交回复
热议问题