How do i read coordinates from a list and store them in arrays | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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.

3rd Nov 2019, 3:01 PM
M.J.
M.J. - avatar
2 Answers
+ 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.
3rd Nov 2019, 5:01 PM
Avinesh
Avinesh - avatar