I have a nested for loop with about 8 loops nested within each other.
for (int n = 0; n < arrayAhu01.length(); n++) {
JSONObject jsonAhu01 = arrayAhu01.getJSONObject(n);
cell4 = newCell(o1Arow, 3.25,jsonAhu01.get("TemperaturePVtag").toString());
for (int m = 0; m < arrayAhu02.length(); m++) {
JSONObject jsonAhu02 = arrayAhu02.getJSONObject(m);
cell4 = newCell(o2Arow, 3.25, jsonAhu02.get("TemperaturePVtag").toString());
for (int j = 0; j < arrayAhu05.length(); j++) {
JSONObject jsonAhu05 = arrayAhu05.getJSONObject(j);
cell4 = newCell(o3Arow, 3.25, jsonAhu05.get("HumiditySPtag").toString());
for (int k = 0; k < arrayAhu06.length(); k++) {
JSONObject jsonAhu06 = arrayAhu06.getJSONObject(k);
cell4 = newCell(o4Arow, 3.25, jsonAhu05.get("HumiditySPtag").toString());
}
}
}
}
I want this to work in a way that after each iteration completes for all the loops, the control should go from the innermost for loop to the outermost loop. This is required to fill in rows in a PDF table in java one by one. (Please ignore the codes regarding cells as its related to PDF table) but in my case the iteration for the innermost loop is happening till it is complete and then finally moves to outermost loop and causes memory exception.