+ 1
How do i read coordinates from a list and store them in arrays
i have a list of 30 coordinates and i have to store them in either one 2d array or two 1d arrays. for that i have to use split to split the string with the coordinates (for ex. 38.573 , 36.829) by the comma and use Double.parseDouble to turn the string parts into double. How do i do that? i just started learning java and i have no idea.
2 odpowiedzi
+ 1
Or replace the for loop with this code if you want to store into an array.
Coordinates [] arr = new Coordinates [c.size()];
for(int i=0;i<c.size();i++){
arr[i] = c.get(i);
}
for(int i=0;i<c.size();i++){
System.out.println(arr[i]);
}
But I recommend you to use an array list.