The below snippet works fine for me(I used the size())
String itemId;
for (int i = 0; i < itemList.size(); i++) {
JSONObject itemObj = (JSONObject)itemList.get(i);
itemId=(String) itemObj.get("ItemId");
System.out.println(itemId);
}
If it is wrong to use use size() kindly advise