Could someone explain why this works:
Map[] IEXDivMap = new Map[IEXJsonArray.length()];
for (int i = 0; i < IEXJsonArray.length(); i++) {
IEXDivMap[i] = new HashMap();
JSONObject IEXJsonObject = IEXJsonArray.getJSONObject(i);
IEXDivMap[i].put("exDate",IEXJsonObject.getString("exDate"));
IEXDivMap[i].put("amount",IEXJsonObject.getString("amount"));
}
but this doesn't:
Object[] IEXDivMap = new Object[IEXJsonArray.length()];
for (int i = 0; i < IEXJsonArray.length(); i++) {
IEXDivMap[i] = new HashMap();
JSONObject IEXJsonObject = IEXJsonArray.getJSONObject(i);
IEXDivMap[i].put("exDate",IEXJsonObject.getString("exDate"));
IEXDivMap[i].put("amount",IEXJsonObject.getString("amount"));
}
Why can't I have an array of Objects each object being a hashmap?