double firstPrice = prices.getDouble(0);
double totalBalance = 0; for (int i = 0; i < data.length(); i++) { totalBalance += data.getDouble(i); }This code iterates through each item in the array and adds its value to the totalBalance variable. If any of the items in the array are not valid doubles, the code will throw a JSONException. The package library used in the above examples is org.json.