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:
double [][] values = {{FastMath.toRadians(0), FastMath.toRadians(4.28)},
{FastMath.toRadians(10), FastMath.toRadians(4.93)},
{FastMath.toRadians(20), FastMath.toRadians(3.75)}};
Where FastMath.toRadians is a method on each element.
Number of issues:
First logical thing to do is to split the string:
List<String> stringProfileList= Arrays.asList(stringProfile.split(" "));
The output would be "0, 4.28, 10, 4.93, 20, 3.75", so now every element is split by a "," rather than every other.
Then for every 2 elements in the list, I need to assign to an array. Within each Array I apply the FastMath.toRadians() on each element and then I append each array to a larger multidimensional array.
Is this the right way to go about this? I'm getting stuck at implementing for every 2 elements.
I also need to convert these string elements into a double, which doesn't seem to trivial.