[Solved] How to convert a String to a float array?


First you split the string into an array:

String str = "1.2, 3.1, 5.3, 4.5"; 
String[] arrOfStr = str.split(","); 

Then you loop through the array and convert to floats:

import java.util.ArrayList;
ArrayList <Double> volts = new ArrayList<Double>();
for (int i = 0; i < arrOfStr.length; i++) { 
    volts.add(Double.parseDouble(arrOfStr[i]));
}
System.out.println(volts);

4

solved How to convert a String to a float array?