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
What about something like this:
Arrays.stream("0,4.28 10,4.93 20,3.75".split(" ")) //Stream
.map(s ->
Arrays.stream(s.split(",")) // take an individual string like 0,4.28
.map(Double::parseDouble) // and transform it to a double array
.toArray(Double[]::new)
)
.toArray(Double[][]::new);
the result is
$8 ==> Double[3][] {
Double[2] { 0.0, 4.28 },
Double[2] { 10.0, 4.93 },
Double[2] { 20.0, 3.75 }
}