Convert String[] with text to double[]

后端 未结 5 1094
旧巷少年郎
旧巷少年郎 2021-01-29 15:02

I have an Arraylist that I want to convert to a double[] array. I first convert the Arraylist to a String []. I then try to convert the String[] to a double[] but fail in the p

5条回答
  •  日久生厌
    2021-01-29 15:41

    Loop throug the Array:

    foreach String[]
        double[counter] = parseToDouble(String[counter])
    

    EDIT:
    Java:

       String[] str1 = list1.toArray(str1);
       double[] dou1 = new double[str1.length]
       for(int counter = 0; counter < str1.length;counter++)
          dou1[counter] = Double.parseDouble(str1[counter].replaceAll("RSP_\\d+",""));
    

提交回复
热议问题