0
JSONArray historyJson = new JSONArray(nameHistoryResponse);
    for (Object o : historyJson) {
        index++;
        JSONObject jsonObj = (JSONObject) o;
        String name = jsonObj.getString("name");
        if (name.equalsIgnoreCase(data[2].toString())) {
            foundIndex = index;
        }
    }

I keep getting an error on line two, saying that historyJson must be "java.lang.Iterable" but according to my code it is. Im completely stumped it would mean the world if someone had a fix for this as the project needs to be done within the next 2 hours.

Abdel Seaf
  • 39
  • 8
  • 1
    doesn't seem like `JSONArray` implements `Iterable`, try to use a `for` loop instead. – Ousmane D. Apr 15 '18 at 15:19
  • I am using a for loop, do you mean replace historyJson with nameHistoryResponse? – Abdel Seaf Apr 15 '18 at 15:20
  • technically speaking, you're using an _enhanced for loop_ which is different to the for loop I've suggested. see the suggested duplicates for the answer to your problem. – Ousmane D. Apr 15 '18 at 15:26

0 Answers0