Dynamically inserting string into a string array in Android
Use ArrayList although it is not really needed but just learn it:
ArrayList<String> stringArrayList = new ArrayList<String>();
for (int i=0; i<jArray.length(); i++) {
JSONObject json_data = jArray.getJSONObject(i);
stringArrayList.add(json_data.getString("xCoord")); //add to arraylist
}
//if you want your array
String [] stringArray = stringArrayList.toArray(new String[stringArrayList.size()]);
Try like this
String stringArray[];
stringArray=new String[jArray.length()];
String xCoords[]=new String[jArray.length()];;
for (int i=0; i<jArray.length(); i++) {
JSONObject json_data = jArray.getJSONObject(i);
xCoords[i] = json_data.getString("xCoord");
}